From: Jakub Pawlowicz Date: Wed, 9 Sep 2015 12:26:48 +0000 (+0100) Subject: Fixes #655 - shorthand override merging. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=4b832126bb9171b592ce1f9a5c29220a3837371f;p=clean-css.git Fixes #655 - shorthand override merging. When multiplex shorthand follows a non-multiplex shorthand then skip merging as it's likely a fallback. --- diff --git a/History.md b/History.md index 3ccd4fe4..c61e9e23 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ [3.4.2 / 2015-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.1...3.4) ================== +* Fixed issue [#655](https://github.com/jakubpawlowicz/clean-css/issues/655) - shorthands override merging. * Fixed issue [#660](https://github.com/jakubpawlowicz/clean-css/issues/660) - !important token overriding. * Fixed issue [#662](https://github.com/jakubpawlowicz/clean-css/issues/662) - !important selector reducing. diff --git a/lib/properties/override-compactor.js b/lib/properties/override-compactor.js index c25ce798..d795be6c 100644 --- a/lib/properties/override-compactor.js +++ b/lib/properties/override-compactor.js @@ -306,6 +306,9 @@ function compactOverrides(properties, compatibility, validator) { } else if (left.shorthand && right.shorthand && left.name == right.name) { // merge if all components can be merged + if (!left.multiplex && right.multiplex) + continue; + if (!right.important && left.important) { right.unused = true; continue propertyLoop; diff --git a/test/properties/override-compacting-test.js b/test/properties/override-compacting-test.js index ec9b07da..7a73b400 100644 --- a/test/properties/override-compacting-test.js +++ b/test/properties/override-compacting-test.js @@ -473,6 +473,15 @@ vows.describe(optimize) } }) .addBatch({ + 'shorthand then shorthand multiplex': { + 'topic': 'p{background:url(one.png);background:url(two.png) center 1px,url(three.png) center 2px}', + 'into': function (topic) { + assert.deepEqual(_optimize(topic), [ + [['background'], ['url(one.png)']], + [['background'], ['url(two.png)'], ['center'], ['1px'], [','], ['url(three.png)'], ['center'], ['2px']] + ]); + } + }, 'shorthand then longhand multiplex': { 'topic': 'p{background:top left;background-repeat:no-repeat,no-repeat}', 'into': function (topic) {