Fixes #447 - `background-color` in shorthands.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Sat, 31 Jan 2015 10:11:46 +0000 (10:11 +0000)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Sat, 31 Jan 2015 10:25:55 +0000 (10:25 +0000)
Apparently `background-color` with a value of `none` can't be merged
into a shorthand as `none` value will override `background-image`.

History.md
lib/properties/override-compactor.js
lib/properties/processable.js
test/integration-test.js

index 8e52884..e74d80b 100644 (file)
@@ -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)
index aaa2c12..7b2981d 100644 (file)
@@ -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);
index 76913c1..5122f49 100644 (file)
@@ -673,6 +673,7 @@ module.exports = (function () {
       canOverride: canOverride.color,
       defaultValue: 'transparent',
       multiValueLastOnly: true,
+      nonMergeableValue: 'none',
       shortestValue: 'red'
     },
     'background-image': {
index 0b15265..bf637b1 100644 (file)
@@ -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}'