From c66692d5ab45f8bb3a79bff6d461a0c445b3ada1 Mon Sep 17 00:00:00 2001 From: Jakub Pawlowicz Date: Thu, 2 Oct 2014 15:49:06 +0100 Subject: [PATCH] Fixes tokenizing escaped content within selectors. --- lib/selectors/tokenizer.js | 3 +++ test/selectors/tokenizer-test.js | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/selectors/tokenizer.js b/lib/selectors/tokenizer.js index 83857ca7..177740c3 100644 --- a/lib/selectors/tokenizer.js +++ b/lib/selectors/tokenizer.js @@ -73,6 +73,9 @@ function whatsNext(context) { var nextBodyStart = chunk.indexOf('{', context.cursor); var nextBodyEnd = chunk.indexOf('}', context.cursor); + if (nextEscape > -1 && /\S/.test(chunk.substring(context.cursor, nextEscape))) + nextEscape = -1; + closest = nextSpecial; if (closest == -1 || (nextEscape > -1 && nextEscape < closest)) closest = nextEscape; diff --git a/test/selectors/tokenizer-test.js b/test/selectors/tokenizer-test.js index 39e77a73..5c08c7ce 100644 --- a/test/selectors/tokenizer-test.js +++ b/test/selectors/tokenizer-test.js @@ -57,6 +57,10 @@ vows.describe(Tokenizer) 'a{color:red; ; ; ;}', [{ selector: ['a'], body: ['color:red'] }] ], + 'a selector with quoted attribute': [ + 'a[data-kind=__ESCAPED_FREE_TEXT_CLEAN_CSS0__]{color:red}', + [{ selector: ['a[data-kind=__ESCAPED_FREE_TEXT_CLEAN_CSS0__]'], body: ['color:red'] }] + ], 'a double selector': [ 'a,\n\ndiv.class > p {color:red}', [{ selector: ['a', 'div.class > p'], body: ['color:red'] }] @@ -91,6 +95,10 @@ vows.describe(Tokenizer) 'charset after a line break': [ '\n@charset \n\'utf-8\';', ['@charset \'utf-8\';'] + ], + 'keyframes with quoted attribute': [ + '@keyframes __ESCAPED_FREE_TEXT_CLEAN_CSS0__{}', + [{ block: '@keyframes __ESCAPED_FREE_TEXT_CLEAN_CSS0__', body: [], isFlatBlock: false }] ] }) ) -- 2.34.1