From 1a4d8718995ca9a68fa65df2aa5a15d5835e4aed Mon Sep 17 00:00:00 2001 From: Andrew Crites Date: Mon, 11 Aug 2014 18:33:45 -0400 Subject: [PATCH] Fix #337 -- component importance. If a matching component and the corresponding token are both important, treat it as if neither is --- History.md | 5 +++++ lib/properties/override-compactor.js | 2 +- test/data/issue-337-min.css | 1 + test/data/issue-337.css | 4 ++++ 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 test/data/issue-337-min.css create mode 100644 test/data/issue-337.css diff --git a/History.md b/History.md index 5664b46f..3e0edbac 100644 --- a/History.md +++ b/History.md @@ -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) ================== diff --git a/lib/properties/override-compactor.js b/lib/properties/override-compactor.js index 418cad2d..6d0759e6 100644 --- a/lib/properties/override-compactor.js +++ b/lib/properties/override-compactor.js @@ -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 index 00000000..bd35bdc3 --- /dev/null +++ b/test/data/issue-337-min.css @@ -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 index 00000000..5baa5bdc --- /dev/null +++ b/test/data/issue-337.css @@ -0,0 +1,4 @@ +div { + background: #eeeeee !important; + background-color: #ffffff !important; +} -- 2.34.1