From 021dce2c1accdb23525fee61c49ee86392864d97 Mon Sep 17 00:00:00 2001 From: Jakub Pawlowicz Date: Sun, 14 Jun 2015 14:52:45 +0100 Subject: [PATCH] Fixes #595 - more relaxed flat block matching. 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 | 1 + lib/tokenizer/tokenize.js | 2 +- test/tokenizer/tokenizer-test.js | 10 ++++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 0b9ef14f..77f5452c 100644 --- a/History.md +++ b/History.md @@ -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) diff --git a/lib/tokenizer/tokenize.js b/lib/tokenizer/tokenize.js index b779a9ce..6fd5f473 100644 --- a/lib/tokenizer/tokenize.js +++ b/lib/tokenizer/tokenize.js @@ -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); diff --git a/test/tokenizer/tokenizer-test.js b/test/tokenizer/tokenizer-test.js index d0721fab..7b40186d 100644 --- a/test/tokenizer/tokenizer-test.js +++ b/test/tokenizer/tokenizer-test.js @@ -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']]] + ] + ] ] }) ) -- 2.34.1