Fixes #220 - universal selector between two comments.
authorGoalSmashers <jakub@goalsmashers.com>
Sat, 1 Feb 2014 07:47:17 +0000 (07:47 +0000)
committerGoalSmashers <jakub@goalsmashers.com>
Sat, 1 Feb 2014 07:47:17 +0000 (07:47 +0000)
Comments were incorrectly processed when universal selector was placed in between.

History.md
lib/text/comments.js
test/unit-test.js

index 0c6e632..d6ed550 100644 (file)
@@ -14,6 +14,7 @@
 * Fixed issue [#207](https://github.com/GoalSmashers/clean-css/issues/207) - bug in parsing protocol `@import`s.
 * Fixed issue [#213](https://github.com/GoalSmashers/clean-css/issues/213) - faster rgb to hex transforms.
 * Fixed issue [#218](https://github.com/GoalSmashers/clean-css/issues/218) - `@import` statements cleanup.
+* Fixed issue [#220](https://github.com/GoalSmashers/clean-css/issues/220) - selector between comments.
 
 [2.0.7 / 2014-01-16](https://github.com/GoalSmashers/clean-css/compare/v2.0.6...v2.0.7)
 ==================
index 8aa7d3c..f6913c8 100644 (file)
@@ -14,7 +14,7 @@ module.exports = function Comments(keepSpecialComments, keepBreaks, lineBreak) {
       var cursor = 0;
 
       for (; nextEnd < data.length;) {
-        nextStart = data.indexOf('/*', nextEnd);
+        nextStart = data.indexOf('/*', cursor);
         nextEnd = data.indexOf('*/', nextStart + 2);
         if (nextStart == -1 || nextEnd == -1)
           break;
index 6f3bb30..165ed28 100644 (file)
@@ -292,6 +292,10 @@ vows.describe('clean-units').addBatch({
     'should properly handle line breaks and ** characters inside comments': [
       '/**====**\\\n/**2nd comment line/**===**/a{color:red}',
       'a{color:red}'
+    ],
+    'selector between comments': [
+      '/*comment*/*/*comment*/{color:red}',
+      '*{color:red}'
     ]
   }),
   'important comments - one': cssContext({