From: Jakub Pawlowicz Date: Mon, 20 Apr 2015 21:24:01 +0000 (+0100) Subject: Fixes #537 - regression in simple optimizer. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=27aa85e091be40941cc58814af078329fde9ab82;p=clean-css.git Fixes #537 - regression in simple optimizer. 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. --- diff --git a/History.md b/History.md index 1c3e608a..6d408505 100644 --- a/History.md +++ b/History.md @@ -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) ================== diff --git a/lib/selectors/optimizers/simple.js b/lib/selectors/optimizers/simple.js index 8cc78824..c619f811 100644 --- a/lib/selectors/optimizers/simple.js +++ b/lib/selectors/optimizers/simple.js @@ -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); diff --git a/test/selectors/optimizers/simple-test.js b/test/selectors/optimizers/simple-test.js index 5e962b90..5c38f8d5 100644 --- a/test/selectors/optimizers/simple-test.js +++ b/test/selectors/optimizers/simple-test.js @@ -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']] ] }) )