Fixes #537 - regression in simple optimizer.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Mon, 20 Apr 2015 21:24:01 +0000 (22:24 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Tue, 21 Apr 2015 06:38:02 +0000 (07:38 +0100)
Value minifiers do not work on many values at ones, so we need to
check the position when doing minification for properties that allow
more than one.

History.md
lib/selectors/optimizers/simple.js
test/selectors/optimizers/simple-test.js

index 1c3e608..6d40850 100644 (file)
@@ -3,6 +3,11 @@
 
 * Fixed issue [#436](https://github.com/jakubpawlowicz/clean-css/issues/436) - refactors URI rewriting.
 
+[3.2.2 / 2015-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v3.2.1...3.2)
+==================
+
+* Fixed issue [#537](https://github.com/jakubpawlowicz/clean-css/issues/537) - regression in simple optimizer.
+
 [3.2.1 / 2015-04-20](https://github.com/jakubpawlowicz/clean-css/compare/v3.2.0...v3.2.1)
 ==================
 
index 8cc7882..c619f81 100644 (file)
@@ -29,8 +29,8 @@ function SimpleOptimizer(options) {
 }
 
 var valueMinifiers = {
-  'background': function (value) {
-    return value == 'none' || value == 'transparent' ? '0 0' : value;
+  'background': function (value, index, total) {
+    return index == 1 && total == 2 && (value == 'none' || value == 'transparent') ? '0 0' : value;
   },
   'font-weight': function (value) {
     if (value == 'normal')
@@ -40,8 +40,8 @@ var valueMinifiers = {
     else
       return value;
   },
-  'outline': function (value) {
-    return value == 'none' ? '0' : value;
+  'outline': function (value, index, total) {
+    return index == 1 && total == 2 && value == 'none' ? '0' : value;
   }
 };
 
@@ -247,7 +247,7 @@ function optimizeBody(properties, options) {
       value = property[j][0];
 
       if (valueMinifiers[name])
-        value = valueMinifiers[name](value);
+        value = valueMinifiers[name](value, j, m);
 
       value = whitespaceMinifier(name, value);
       value = precisionMinifier(name, value, options.precision);
index 5e962b9..5c38f8d 100644 (file)
@@ -141,6 +141,10 @@ vows.describe(SimpleOptimizer)
       'any other': [
         'a{background:red}',
         [['background', 'red']]
+      ],
+      'none to other': [
+        'a{background:transparent no-repeat}',
+        [['background', 'transparent', 'no-repeat']]
       ]
     })
   )
@@ -373,6 +377,10 @@ vows.describe(SimpleOptimizer)
       'any other': [
         'a{outline:10px}',
         [['outline', '10px']]
+      ],
+      'none and any other': [
+        'a{outline:none solid 1px}',
+        [['outline', 'none', 'solid', '1px']]
       ]
     })
   )