Fixes wrong @import handling in EmptyRemoval.
authorJakub Pawlowicz <jakub@goalsmashers.com>
Mon, 10 Mar 2014 07:51:18 +0000 (07:51 +0000)
committerJakub Pawlowicz <jakub@goalsmashers.com>
Mon, 10 Mar 2014 07:55:27 +0000 (07:55 +0000)
Since @import declarations are special to any selectors or blocks
these were not handled properly in EmptyRemoval.

History.md
lib/selectors/empty-removal.js
test/unit-test.js

index eaf1677..f86518c 100644 (file)
 * 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)
 ==================
 
index 7af188d..5ce39c8 100644 (file)
@@ -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));
index fc986e3..1e70fd6 100644 (file)
@@ -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 }),