Adds ignoring misplaced top level curly braces.
authorGoalSmashers <jakub@goalsmashers.com>
Fri, 1 Nov 2013 17:14:41 +0000 (18:14 +0100)
committerGoalSmashers <jakub@goalsmashers.com>
Sun, 3 Nov 2013 08:49:23 +0000 (09:49 +0100)
lib/selectors/tokenizer.js
test/unit-test.js

index 160404f..2737d2d 100644 (file)
@@ -94,6 +94,12 @@ module.exports = function Tokenizer(data) {
 
         tokenized.push({ selector: selector, body: body });
       } else if (what == 'bodyEnd') {
+        // extra closing brace at the top level can be safely ignored
+        if (context.mode == 'top' && data[context.cursor] == '}') {
+          context.cursor += 1;
+          continue;
+        }
+
         if (context.mode != 'block') {
           tokenized = data.substring(context.cursor, nextSpecial);
         }
index c85d78e..ff105ba 100644 (file)
@@ -1069,6 +1069,16 @@ title']{display:block}",
   'duplicate selectors with disabled advanced processing': cssContext({
     'of a duplicate selector': 'a,a{color:red}'
   }, { noAdvanced: true }),
+  'invalid data tokenization': cssContext({
+    'extra top-level closing brace': [
+      'a{color:red}}p{width:auto}',
+      'a{color:red}p{width:auto}'
+    ],
+    'extra top-level closing braces': [
+      'a{color:red}}}}p{width:auto}',
+      'a{color:red}p{width:auto}'
+    ]
+  }),
   'duplicate selectors in a list': cssContext({
     'of a duplicate selector': [
       'a,a{color:red}',