Fix #337 -- component importance.
authorAndrew Crites <acrites@mobiquityinc.com>
Mon, 11 Aug 2014 22:33:45 +0000 (18:33 -0400)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Tue, 12 Aug 2014 21:34:52 +0000 (22:34 +0100)
If a matching component and the corresponding token are both important, treat it as if neither is

History.md
lib/properties/override-compactor.js
test/data/issue-337-min.css [new file with mode: 0644]
test/data/issue-337.css [new file with mode: 0644]

index 5664b46..3e0edba 100644 (file)
@@ -1,3 +1,8 @@
+[2.2.13 / 2014-xx-xx](https://github.com/GoalSmashers/clean-css/compare/v2.2.12...v2.2.13)
+==================
+
+* Fixed issue [#337](https://github.com/GoalSmashers/clean-css/issues/337) - handling component importance.
+
 [2.2.12 / 2014-08-02](https://github.com/GoalSmashers/clean-css/compare/v2.2.11...v2.2.12)
 ==================
 
index 418cad2..6d0759e 100644 (file)
@@ -71,7 +71,7 @@ module.exports = (function () {
           if (can(matchingComponent.value, token.value)) {
             // The component can override the matching component in the shorthand
 
-            if (!token.isImportant) {
+            if (!token.isImportant || token.isImportant && matchingComponent.isImportant) {
               // The overriding component is non-important which means we can simply include it into the shorthand
               // NOTE: stuff that can't really be included, like inherit, is taken care of at the final step, not here
               matchingComponent.value = token.value;
diff --git a/test/data/issue-337-min.css b/test/data/issue-337-min.css
new file mode 100644 (file)
index 0000000..bd35bdc
--- /dev/null
@@ -0,0 +1 @@
+div{background:#fff!important}
diff --git a/test/data/issue-337.css b/test/data/issue-337.css
new file mode 100644 (file)
index 0000000..5baa5bd
--- /dev/null
@@ -0,0 +1,4 @@
+div {
+  background: #eeeeee !important;
+  background-color: #ffffff !important;
+}