From 7fdea17d97527a2b3a755fb84cac405a21fad3e2 Mon Sep 17 00:00:00 2001 From: GoalSmashers Date: Thu, 14 Nov 2013 09:31:30 +0100 Subject: [PATCH] Fixes #176 - hangs when `undefined` is used as a property value. --- History.md | 5 +++++ lib/selectors/optimizer.js | 2 +- test/unit-test.js | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 9092156a..6ef61f3b 100644 --- a/History.md +++ b/History.md @@ -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) ================== diff --git a/lib/selectors/optimizer.js b/lib/selectors/optimizer.js index 8a344e9f..b10ae788 100644 --- a/lib/selectors/optimizer.js +++ b/lib/selectors/optimizer.js @@ -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; } diff --git a/test/unit-test.js b/test/unit-test.js index 9faaa436..42eba554 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -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({ -- 2.34.1