From 85f87b08ed7e91eec416bd0e27db090c38bd0e33 Mon Sep 17 00:00:00 2001 From: Jakub Pawlowicz Date: Tue, 11 Apr 2017 12:12:15 +0200 Subject: [PATCH] Fixes #930 - regression in tidying selectors. Why: * `null` is not a safe argument to `replace` method as it's interpreted as a text pattern. --- History.md | 5 +++++ lib/optimizer/level-1/tidy-rules.js | 6 +++--- test/optimizer/level-1/optimize-test.js | 8 ++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 28a0c7a9..cc5f4917 100644 --- a/History.md +++ b/History.md @@ -11,6 +11,11 @@ * Fixed issue [#755](https://github.com/jakubpawlowicz/clean-css/issues/755) - adds custom handling of remote requests. * Fixed issue [#254](https://github.com/jakubpawlowicz/clean-css/issues/254) - adds `font` property optimizer. +[4.0.12 / 2017-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v4.0.11...4.0) +================== + +* Fixed issue [#930](https://github.com/jakubpawlowicz/clean-css/issues/930) - regression in tidying selectors. + [4.0.11 / 2017-04-04](https://github.com/jakubpawlowicz/clean-css/compare/v4.0.10...v4.0.11) ================== diff --git a/lib/optimizer/level-1/tidy-rules.js b/lib/optimizer/level-1/tidy-rules.js index 5aba2c7b..b47ed6b7 100644 --- a/lib/optimizer/level-1/tidy-rules.js +++ b/lib/optimizer/level-1/tidy-rules.js @@ -135,9 +135,9 @@ function removeWhitespace(value, format) { wasWhitespace = isWhitespace; } - return stripped - .join('') - .replace(withCaseAttribute ? CASE_RESTORE_PATTERN : null, '$1 $2]'); + return withCaseAttribute ? + stripped.join('').replace(CASE_RESTORE_PATTERN, '$1 $2]') : + stripped.join(''); } function removeQuotes(value) { diff --git a/test/optimizer/level-1/optimize-test.js b/test/optimizer/level-1/optimize-test.js index a8c8357f..89885cbd 100644 --- a/test/optimizer/level-1/optimize-test.js +++ b/test/optimizer/level-1/optimize-test.js @@ -144,6 +144,14 @@ vows.describe('level 1 optimizations') 'missing semicolon and brace in the middle': [ 'body{color:red a{color:blue;}', '' + ], + 'null as a selector name': [ + '.null{color:red}', + '.null{color:red}' + ], + 'null inside selector name': [ + '.block--null{color:red}', + '.block--null{color:red}' ] }, { level: 1 }) ) -- 2.34.1