From 9bdf3ac00f4da7353992592319af2d8c3256a0a3 Mon Sep 17 00:00:00 2001 From: Jakub Pawlowicz Date: Sat, 5 Sep 2015 20:00:23 +0100 Subject: [PATCH] Fixes #660 - override compacting of !important properties. We were not copying properties when assigning in four-values tokens. As a result we were adding !important value to all components as they were referencing the same object. --- History.md | 5 +++++ lib/properties/break-up.js | 6 +++--- test/properties/shorthand-compacting-test.js | 8 ++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index c470d12c..a3aa7bea 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +[3.4.2 / 2015-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.1...3.4) +================== + +* Fixed issue [#660](https://github.com/jakubpawlowicz/clean-css/issues/660) - !important token overriding. + [3.4.1 / 2015-08-27](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.0...v3.4.1) ================== diff --git a/lib/properties/break-up.js b/lib/properties/break-up.js index ae9701d2..d803536a 100644 --- a/lib/properties/break-up.js +++ b/lib/properties/break-up.js @@ -159,11 +159,11 @@ function fourValues(property, compactable) { return []; if (value.length < 2) - value[1] = value[0]; + value[1] = value[0].slice(0); if (value.length < 3) - value[2] = value[0]; + value[2] = value[0].slice(0); if (value.length < 4) - value[3] = value[1]; + value[3] = value[1].slice(0); for (var i = componentNames.length - 1; i >= 0; i--) { var component = wrapSingle([[componentNames[i], property.important]]); diff --git a/test/properties/shorthand-compacting-test.js b/test/properties/shorthand-compacting-test.js index 11893e12..bee1225b 100644 --- a/test/properties/shorthand-compacting-test.js +++ b/test/properties/shorthand-compacting-test.js @@ -85,6 +85,14 @@ vows.describe(optimize) ]); } }, + 'shorthand multiple !important': { + 'topic': 'a{border-color:#123 !important;border-top-color: #456 !important}', + 'into': function (topic) { + assert.deepEqual(_optimize(topic), [ + [['border-color'], ['#456'], ['#123'], ['#123!important']] + ]); + } + }, 'shorthand list-style #1': { 'topic': 'a{list-style-type:circle;list-style-position:outside;list-style-image:__ESCAPED_URL_CLEAN_CSS0__}', 'into': function (topic) { -- 2.34.1