Refixes #325 - invalid charset declarations.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Sat, 2 Aug 2014 09:41:12 +0000 (10:41 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Sat, 2 Aug 2014 10:40:24 +0000 (11:40 +0100)
* All incorrect, non-lowercase charsets are being now removed.
* Removes stripping @IMPORT declarations.

History.md
lib/clean.js
test/unit-test.js

index 8db3e3d..c3c79b3 100644 (file)
@@ -3,6 +3,7 @@
 
 * Fixed issue with tokenizer removing first selector after an unknown @ rule.
 * Fixed issue [#329](https://github.com/GoalSmashers/clean-css/issues/329) - font shorthands incorrectly processed.
+* Refixed issue [#325](https://github.com/GoalSmashers/clean-css/issues/325) - invalid charset declarations.
 
 [2.2.11 / 2014-07-28](https://github.com/GoalSmashers/clean-css/compare/v2.2.10...v2.2.11)
 ==================
index 8843413..704c2d8 100644 (file)
@@ -190,7 +190,9 @@ var minify = function(data, callback) {
   });
 
   // remove invalid special declarations
-  replace(/@(?:IMPORT|CHARSET) [^;]+;/g, '');
+  replace(/@charset [^;]+;/ig, function (match) {
+    return match.indexOf('@charset') > -1 ? match : '';
+  });
 
   // whitespace inside attribute selectors brackets
   replace(/\[([^\]]+)\]/g, function(match) {
index accc8b1..fc5ba6b 100644 (file)
@@ -225,6 +225,10 @@ vows.describe('clean-units').addBatch({
     'uppercase charset': [
       "@CHARSET 'utf-8';h1{color:red}",
       'h1{color:red}'
+    ],
+    'mixed case charset': [
+      "@chArSET 'utf-8';h1{color:red}",
+      'h1{color:red}'
     ]
   }, { keepBreaks: true }),
   'line breaks and important comments': cssContext({