Fixes #595 - more relaxed flat block matching.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Sun, 14 Jun 2015 13:52:45 +0000 (14:52 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Sun, 14 Jun 2015 14:56:53 +0000 (15:56 +0100)
Apparently there are IE hacks that allow mixing flat block
declarations with pseudoselectors:

```css
/* IE 10 special css */
_:-ms-lang(x), @-ms-viewport {
  width: auto\9 !important;
}
```

History.md
lib/tokenizer/tokenize.js
test/tokenizer/tokenizer-test.js

index 0b9ef14..77f5452 100644 (file)
@@ -1,6 +1,7 @@
 [3.3.2 / 2015-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.1...3.3)
 ==================
 
+* Fixed issue [#595](https://github.com/jakubpawlowicz/clean-css/issues/595) - more relaxed block matching.
 * Fixed issue [#601](https://github.com/jakubpawlowicz/clean-css/issues/601) - percentage minifying inside `flex`.
 
 [3.3.1 / 2015-06-02](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.0...v3.3.1)
index b779a9c..6fd5f47 100644 (file)
@@ -5,7 +5,7 @@ var track = require('../source-maps/track');
 
 var path = require('path');
 
-var flatBlock = /(^@(font\-face|page|\-ms\-viewport|\-o\-viewport|viewport|counter\-style)|\\@.+?)/;
+var flatBlock = /(@(font\-face|page|\-ms\-viewport|\-o\-viewport|viewport|counter\-style)|\\@.+?)/;
 
 function tokenize(data, outerContext) {
   var chunker = new Chunker(normalize(data), '}', 128);
index d0721fa..7b40186 100644 (file)
@@ -256,6 +256,16 @@ vows.describe(tokenize)
             [[['color'], ['red!important']]]
           ]
         ]
+      ],
+      '_:-ms-lang flat block': [
+        '_:-ms-lang(x),@-ms-viewport{color:red}',
+        [
+          [
+            'flat-block',
+            ['_:-ms-lang(x),@-ms-viewport'],
+            [[['color'], ['red']]]
+          ]
+        ]
       ]
     })
   )