Fixes #176 - hangs when `undefined` is used as a property value.
authorGoalSmashers <jakub@goalsmashers.com>
Thu, 14 Nov 2013 08:31:30 +0000 (09:31 +0100)
committerGoalSmashers <jakub@goalsmashers.com>
Thu, 14 Nov 2013 08:33:17 +0000 (09:33 +0100)
History.md
lib/selectors/optimizer.js
test/unit-test.js

index 9092156..6ef61f3 100644 (file)
@@ -1,3 +1,8 @@
+[2.0.1 / 2013-xx-xx](https://github.com/GoalSmashers/clean-css/compare/v2.0.0...HEAD)
+==================
+
+* Fixed issue [#176](https://github.com/GoalSmashers/clean-css/issues/176) - hangs on `undefined` keyword.
+
 [2.0.0 / 2013-11-04](https://github.com/GoalSmashers/clean-css/compare/v1.1.7...v2.0.0)
 ==================
 
index 8a344e9..b10ae78 100644 (file)
@@ -133,7 +133,7 @@ module.exports = function Optimizer(data, options) {
       var currentMatch = matchPositions.length - 1;
 
       while (currentMatch >= 0) {
-        if (bodies[currentMatch].indexOf(optimizedTokens[k]) > -1) {
+        if (bodies[currentMatch].indexOf(optimizedTokens[k]) > -1 && k > -1) {
           k -= 1;
           continue;
         }
index 9faaa43..42eba55 100644 (file)
@@ -1249,6 +1249,11 @@ title']{display:block}",
     'when complex selector overriden by complex selectors': [
       '.one>.two,.three{color:red;line-height:1rem}#zero,.one>.two,.three,.www{color:#fff;margin:0}a{color:red}.one>.two,.three{line-height:2rem;font-size:1.5rem}',
       '#zero,.one>.two,.three,.www{color:#fff;margin:0}a{color:red}.one>.two,.three{line-height:2rem;font-size:1.5rem}'
+    ],
+    'when undefined is used as a value': '.one{text-shadow:undefined}p{color:red}.one{font-size:12px}',
+    'when undefined is used as a value with reduction': [
+      '.one{text-shadow:undefined}p{color:red}.one{font-size:12px;text-shadow:none}',
+      'p{color:red}.one{font-size:12px;text-shadow:none}'
     ]
   }),
   'same bodies': cssContext({