From: Jakub Pawlowicz Date: Thu, 22 Dec 2016 21:18:33 +0000 (+0100) Subject: Fixes #758 - ignores rules with empty selectors. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=a239f68aec7e5ed9ce6717936914ceddef1ccff8;p=clean-css.git Fixes #758 - ignores rules with empty selectors. --- diff --git a/History.md b/History.md index 35cad478..378b51e6 100644 --- a/History.md +++ b/History.md @@ -12,6 +12,7 @@ * Fixed issue [#657](https://github.com/jakubpawlowicz/clean-css/issues/657) - adds property name validation. * Fixed issue [#686](https://github.com/jakubpawlowicz/clean-css/issues/686) - adds rounding precision for all units. * Fixed issue [#756](https://github.com/jakubpawlowicz/clean-css/issues/756) - adds disabling font-weight optimizations. +* Fixed issue [#758](https://github.com/jakubpawlowicz/clean-css/issues/758) - ignores rules with empty selector. * Fixed issue [#817](https://github.com/jakubpawlowicz/clean-css/issues/817) - makes `off` disable rounding. * Fixed issue [#818](https://github.com/jakubpawlowicz/clean-css/issues/818) - disables `px` rounding by default. * Fixed issue [#834](https://github.com/jakubpawlowicz/clean-css/issues/834) - adds extra line break in nested blocks. diff --git a/lib/optimizer/tidy-rules.js b/lib/optimizer/tidy-rules.js index 38bbb3b0..296b757f 100644 --- a/lib/optimizer/tidy-rules.js +++ b/lib/optimizer/tidy-rules.js @@ -187,6 +187,11 @@ function tidyRules(rules, removeUnsupported, adjacentSpace, beautify, warnings) list.push(rule); } + if (list.length == 1 && list[0][1].length === 0) { + warnings.push('Empty selector \'' + list[0][1] + '\' at ' + formatPosition(list[0][2][0]) + '. Ignoring.'); + list = []; + } + return list.sort(ruleSorter); } diff --git a/test/optimizer/basic-test.js b/test/optimizer/basic-test.js index ba712e97..4c9cd54d 100644 --- a/test/optimizer/basic-test.js +++ b/test/optimizer/basic-test.js @@ -100,6 +100,10 @@ vows.describe('simple optimizations') 'quotes #2': [ '.b[data-json=\'"aaaa":"bbbb"\']{color:red}', '.b[data-json=\'"aaaa":"bbbb"\']{color:red}' + ], + 'no rule scope': [ + '{overflow:hidden}', + '' ] }, { advanced: false }) )