From: Jakub Pawlowicz Date: Mon, 10 Mar 2014 07:51:18 +0000 (+0000) Subject: Fixes wrong @import handling in EmptyRemoval. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=1b59c1e0fa34871cc8a3167a5ae865aa546da252;p=clean-css.git Fixes wrong @import handling in EmptyRemoval. Since @import declarations are special to any selectors or blocks these were not handled properly in EmptyRemoval. --- diff --git a/History.md b/History.md index eaf1677f..f86518cd 100644 --- a/History.md +++ b/History.md @@ -13,6 +13,11 @@ * Fixed issue [#247](https://github.com/GoalSmashers/clean-css/issues/247) - removes deprecated `selectorsMergeMode` switch. * Refixed issue [#250](https://github.com/GoalSmashers/clean-css/issues/250) - based on new quotation marks removal. +[2.1.6 / 2014-xx-xx (UNRELEASED)](https://github.com/GoalSmashers/clean-css/compare/v2.1.5...v2.1.6) +================== + +* Fixed issue [#258](https://github.com/GoalSmashers/clean-css/issues/258) - wrong @import handling in EmptyRemoval. + [2.1.5 / 2014-03-07](https://github.com/GoalSmashers/clean-css/compare/v2.1.4...v2.1.5) ================== diff --git a/lib/selectors/empty-removal.js b/lib/selectors/empty-removal.js index 7af188d4..5ce39c81 100644 --- a/lib/selectors/empty-removal.js +++ b/lib/selectors/empty-removal.js @@ -10,7 +10,7 @@ module.exports = function EmptyRemoval(data) { break; var startsAt = nextEmpty - 1; - while (cssData[startsAt] && cssData[startsAt] != '}' && cssData[startsAt] != '{') + while (cssData[startsAt] && cssData[startsAt] != '}' && cssData[startsAt] != '{' && cssData[startsAt] != ';') startsAt--; tempData.push(cssData.substring(cursor, startsAt + 1)); diff --git a/test/unit-test.js b/test/unit-test.js index fc986e36..1e70fd62 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -1275,6 +1275,13 @@ title']{display:block}", "@import url(/fake.css);" ] }, { processImport: false }), + '@import with no import and no advanced': cssContext({ + 'empty body': [ + '@import url(//fonts.googleapis.com/css?family=Domine:700);body{/* comment */}body h1{font-family:Domine}', + '@import url(//fonts.googleapis.com/css?family=Domine:700);body h1{font-family:Domine}' + ], + 'no empty body': '@import url(//fonts.googleapis.com/css?family=Domine:700);body{color:red}body h1{font-family:Domine}' + }, { processImport: false, noAdvanced: true }), 'duplicate selectors with disabled advanced processing': cssContext({ 'of a duplicate selector': 'a,a{color:red}' }, { noAdvanced: true }),