From: Jakub Pawlowicz Date: Sat, 31 Jan 2015 10:11:46 +0000 (+0000) Subject: Fixes #447 - `background-color` in shorthands. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=46cf5defb0808fc5e187e06ad4a35178a9418d4b;p=clean-css.git Fixes #447 - `background-color` in shorthands. Apparently `background-color` with a value of `none` can't be merged into a shorthand as `none` value will override `background-image`. --- diff --git a/History.md b/History.md index 8e528843..e74d80b5 100644 --- a/History.md +++ b/History.md @@ -17,6 +17,7 @@ [3.0.8 / 2015-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v3.0.7...v3.0.8) ================== +* Fixed issue [#447](https://github.com/GoalSmashers/clean-css/issues/447) - `background-color` in shorthands. * Fixed issue [#450](https://github.com/GoalSmashers/clean-css/issues/450) - name to hex color converting. [3.0.7 / 2015-01-22](https://github.com/jakubpawlowicz/clean-css/compare/v3.0.6...v3.0.7) diff --git a/lib/properties/override-compactor.js b/lib/properties/override-compactor.js index aaa2c124..7b2981d8 100644 --- a/lib/properties/override-compactor.js +++ b/lib/properties/override-compactor.js @@ -96,8 +96,8 @@ module.exports = (function () { matchingComponent = t.components.filter(nameMatchFilter1)[0]; if (can(matchingComponent.value, token.value)) { // The component can override the matching component in the shorthand - var disabledForToken = !compatibility.properties.backgroundSizeMerging && - token.prop.indexOf('background-size') > -1; + var disabledForToken = !compatibility.properties.backgroundSizeMerging && token.prop.indexOf('background-size') > -1 || + processable[token.prop].nonMergeableValue && processable[token.prop].nonMergeableValue == token.value; if (disabledForToken) { result.push(t); diff --git a/lib/properties/processable.js b/lib/properties/processable.js index 76913c1c..5122f494 100644 --- a/lib/properties/processable.js +++ b/lib/properties/processable.js @@ -673,6 +673,7 @@ module.exports = (function () { canOverride: canOverride.color, defaultValue: 'transparent', multiValueLastOnly: true, + nonMergeableValue: 'none', shortestValue: 'red' }, 'background-image': { diff --git a/test/integration-test.js b/test/integration-test.js index 0b15265b..bf637b19 100644 --- a/test/integration-test.js +++ b/test/integration-test.js @@ -1938,6 +1938,10 @@ title']{display:block}", 'a{background:0;background-color:inherit}', 'a{background:0;background-color:inherit}' ], + 'should NOT merge background with background-color set to none': [ + 'a{background:url(logo.png)no-repeat center;background-color:none}', + 'a{background:url(logo.png)no-repeat center;background-color:none}' + ], 'should merge background with background-image': [ 'a{background:0;background-image:url(hello_world)}', 'a{background:url(hello_world)0}'