Fixes tokenizing escaped content within selectors.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Thu, 2 Oct 2014 14:49:06 +0000 (15:49 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Fri, 10 Oct 2014 20:22:45 +0000 (21:22 +0100)
lib/selectors/tokenizer.js
test/selectors/tokenizer-test.js

index 83857ca..177740c 100644 (file)
@@ -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;
index 39e77a7..5c08c7c 100644 (file)
@@ -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 }]
       ]
     })
   )