Fixes #255 - incorrect processing of a trailing '-0' in selectors.
authorJakub Pawlowicz <jakub@goalsmashers.com>
Fri, 7 Mar 2014 20:42:15 +0000 (20:42 +0000)
committerJakub Pawlowicz <jakub@goalsmashers.com>
Fri, 7 Mar 2014 20:55:11 +0000 (20:55 +0000)
History.md
lib/clean.js
test/unit-test.js

index bd4df3c..6437ea2 100644 (file)
@@ -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.
 * 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)
 ==================
 
index 9423e9c..a2f0c51 100644 (file)
@@ -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');
index 19b6819..fc986e3 100644 (file)
@@ -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': [