From 86d670e482a8e818c7744807021328a5824e41d7 Mon Sep 17 00:00:00 2001 From: Jakub Pawlowicz Date: Fri, 7 Mar 2014 20:42:15 +0000 Subject: [PATCH] Fixes #255 - incorrect processing of a trailing '-0' in selectors. --- History.md | 7 ++++++- lib/clean.js | 6 ++++-- test/unit-test.js | 4 +++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/History.md b/History.md index bd4df3c1..6437ea26 100644 --- a/History.md +++ b/History.md @@ -1,4 +1,4 @@ -[2.2.0 / 2014-xx-xx (UNRELEASED)](https://github.com/GoalSmashers/clean-css/compare/v2.1.4...HEAD) +[2.2.0 / 2014-xx-xx (UNRELEASED)](https://github.com/GoalSmashers/clean-css/compare/v2.1.5...HEAD) ================== * Adds a better algorithm for quotation marks' removal. @@ -13,6 +13,11 @@ * Fixed issue [#247](https://github.com/GoalSmashers/clean-css/issues/247) - removes deprecated `selectorsMergeMode` switch. * Refixed issue [#250](https://github.com/GoalSmashers/clean-css/issues/250) - based on new quotation marks removal. +[2.1.5 / 2014-xx-xx (UNRELEASED)](https://github.com/GoalSmashers/clean-css/compare/v2.1.4...v2.1.5) +================== + +* Fixed issue [#255](https://github.com/GoalSmashers/clean-css/issues/255) - incorrect processing of a trailing '-0'. + [2.1.4 / 2014-03-01](https://github.com/GoalSmashers/clean-css/compare/v2.1.3...v2.1.4) ================== diff --git a/lib/clean.js b/lib/clean.js index 9423e9cb..a2f0c51a 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -256,8 +256,10 @@ var minify = function(data, callback) { }); // minus zero to zero - replace(/(\s|:|,|\()\-0([^\.])/g, '$10$2'); - replace(/-0([,\)])/g, '0$1'); + // repeated twice on purpose as if not it doesn't process rgba(-0,-0,-0,-0) correctly + var zerosRegexp = /(\s|:|,|\()\-0([^\.])/g; + replace(zerosRegexp, '$10$2'); + replace(zerosRegexp, '$10$2'); // zero(s) + value to value replace(/(\s|:|,)0+([1-9])/g, '$1$2'); diff --git a/test/unit-test.js b/test/unit-test.js index 19b68192..fc986e36 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -258,7 +258,9 @@ vows.describe('clean-units').addBatch({ 'not expand + in selectors mixed with calc methods': [ 'div{width:calc(50% + 3em)}div + div{width:100%}div:hover{width:calc(50% + 4em)}* > div {border:1px solid #f0f}', 'div{width:calc(50% + 3em)}div+div{width:100%}div:hover{width:calc(50% + 4em)}*>div{border:1px solid #f0f}' - ] + ], + 'process selectors ending with -0 correctly': '.selector-0,a{display:block}', + 'process selectors ending with -1 correctly': '.selector-1,a{display:block}' }), 'comments': cssContext({ 'single line': [ -- 2.34.1