Fixes #957 - `0%` minification of `width` property.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Fri, 14 Jul 2017 12:42:04 +0000 (14:42 +0200)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Fri, 14 Jul 2017 12:51:41 +0000 (14:51 +0200)
Why:

* Apparently `width` and `max-width` `0%` value cannot be turned into
  `0`, see: https://codepen.io/judowalker/pen/xrMxWj

History.md
lib/optimizer/level-1/optimize.js
test/optimizer/level-1/optimize-test.js

index 3a38aa8..eb9ba80 100644 (file)
@@ -6,6 +6,11 @@
 * Fixed issue [#895](https://github.com/jakubpawlowicz/clean-css/issues/895) - ignoring specific styles.
 * Fixed issue [#947](https://github.com/jakubpawlowicz/clean-css/issues/947) - selector based filtering.
 
+[4.1.7 / 2017-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v4.1.6...4.1)
+==================
+
+* Fixed issue [#957](https://github.com/jakubpawlowicz/clean-css/issues/957) - `0%` minification of `width` property.
+
 [4.1.6 / 2017-07-08](https://github.com/jakubpawlowicz/clean-css/compare/v4.1.5...v4.1.6)
 ==================
 
index 2d08bc7..574267c 100644 (file)
@@ -271,7 +271,7 @@ function optimizeUnits(name, value, unitsRegexp) {
     return value;
   }
 
-  if (value.indexOf('%') > 0 && (name == 'height' || name == 'max-height')) {
+  if (value.indexOf('%') > 0 && (name == 'height' || name == 'max-height' || name == 'width' || name == 'max-width')) {
     return value;
   }
 
index 8b85c61..9dd549d 100644 (file)
@@ -894,8 +894,8 @@ vows.describe('level 1 optimizations')
         'a{margin:0}'
       ],
       '-0% to 0': [
-        'a{width:-0%}',
-        'a{width:0}'
+        'a{min-width:-0%}',
+        'a{min-width:0}'
       ],
       'missing': [
         'a{opacity:1.}',
@@ -968,6 +968,18 @@ vows.describe('level 1 optimizations')
       'max-height': [
         'a{max-height:0%}',
         'a{max-height:0%}'
+      ],
+      'width': [
+        'a{width:0%}',
+        'a{width:0%}'
+      ],
+      'min-width': [
+        'a{min-width:0%}',
+        'a{min-width:0}'
+      ],
+      'max-width': [
+        'a{max-width:0%}',
+        'a{max-width:0%}'
       ]
     }, { level: 1 })
   )