Fixes #750 - allows `width` overriding.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Sat, 31 Dec 2016 18:02:31 +0000 (19:02 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Sun, 1 Jan 2017 11:21:15 +0000 (12:21 +0100)
Why:

* Width can be overriden easily using `unit` overrider.

History.md
lib/properties/compactable.js
test/optimizer/advanced-test.js
test/properties/override-compacting-test.js

index b610d29..3c846c7 100644 (file)
@@ -16,6 +16,7 @@
 * Fixed issue [#686](https://github.com/jakubpawlowicz/clean-css/issues/686) - adds rounding precision for all units.
 * Fixed issue [#703](https://github.com/jakubpawlowicz/clean-css/issues/703) - changes default IE compatibility to 10+.
 * Fixed issue [#739](https://github.com/jakubpawlowicz/clean-css/issues/739) - error when a closing brace is missing.
+* Fixed issue [#750](https://github.com/jakubpawlowicz/clean-css/issues/750) - allows `width` overriding.
 * Fixed issue [#756](https://github.com/jakubpawlowicz/clean-css/issues/756) - adds disabling font-weight optimizations.
 * Fixed issue [#758](https://github.com/jakubpawlowicz/clean-css/issues/758) - ignores rules with empty selector.
 * Fixed issue [#767](https://github.com/jakubpawlowicz/clean-css/issues/767) - disables remote `@import` inlining by default.
index 9abc2df..ca0657d 100644 (file)
@@ -190,6 +190,11 @@ var compactable = {
   },
   'transform': {
     canOverride: canOverride.sameFunctionOrValue
+  },
+  'width': {
+    canOverride: canOverride.unit,
+    defaultValue: 'auto',
+    shortestValue: '0'
   }
 };
 
index 01cdbb0..d89a81c 100644 (file)
@@ -86,4 +86,12 @@ vows.describe('advanced optimizer')
       ]
     })
   )
+  .addBatch(
+    optimizerContext('unit compacting', {
+      'width': [
+        'div{width:1rem;width:16px}',
+        'div{width:16px}'
+      ]
+    })
+  )
   .export(module);
index 1c0f04b..7ad2f1d 100644 (file)
@@ -1606,4 +1606,39 @@ vows.describe(optimize)
       }
     }
   })
+  .addBatch({
+    'one unit value': {
+      'topic': function () {
+        return _optimize('a{width:3px;width:4px}');
+      },
+      'into': function (properties) {
+        assert.deepEqual(properties, [
+          [
+            'property',
+            ['property-name', 'width', [[1, 12, undefined]]],
+            ['property-value', '4px', [[1, 18, undefined]]]
+          ]
+        ]);
+      }
+    },
+    'incompatible unit values': {
+      'topic': function () {
+        return _optimize('a{width:4px;width:calc(5rem / 2)}');
+      },
+      'into': function (properties) {
+        assert.deepEqual(properties, [
+          [
+            'property',
+            ['property-name', 'width', [[1, 2, undefined]]],
+            ['property-value', '4px', [[1, 8, undefined]]]
+          ],
+          [
+            'property',
+            ['property-name', 'width', [[1, 12, undefined]]],
+            ['property-value', 'calc(5rem / 2)', [[1, 18, undefined]]]
+          ]
+        ]);
+      }
+    }
+  })
   .export(module);