Fixes stray whitespace tracking in blocks (@media, etc).
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Fri, 7 Nov 2014 18:51:41 +0000 (18:51 +0000)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Mon, 8 Dec 2014 09:39:14 +0000 (09:39 +0000)
lib/selectors/tokenizer.js
test/selectors/tokenizer-source-maps-test.js

index d1c727c..2a45316 100644 (file)
@@ -207,6 +207,8 @@ function tokenize(context) {
         continue;
       }
 
+      if (context.mode == 'block' && context.addSourceMap)
+        SourceMaps.track(chunk.substring(context.cursor, nextSpecial), context);
       if (context.mode != 'block')
         tokenized = chunk.substring(context.cursor, nextSpecial);
 
index e72589d..99d5643 100644 (file)
@@ -279,6 +279,29 @@ vows.describe('source-maps/analyzer')
           }
         ]
       ],
+      '@media - stray whitespace at end': [
+        '@media (min-width:980px){a{color:red} }p{color:red}',
+        [
+          {
+            kind: 'block',
+            value: '@media (min-width:980px)',
+            metadata: { line: 1, column: 1, source: undefined },
+            isFlatBlock: false,
+            body: [
+              {
+                kind: 'selector',
+                value: [{ value: 'a', metadata: { line: 1, column: 26, source: undefined } }],
+                body: [{ value: 'color:red', metadata: { line: 1, column: 28, source: undefined } }]
+              },
+            ]
+          },
+          {
+            kind: 'selector',
+            value: [{ value: 'p', metadata: { line: 1, column: 40, source: undefined } }],
+            body: [{ value: 'color:red', metadata: { line: 1, column: 42, source: undefined } }]
+          }
+        ]
+      ],
       '@font-face': [
         '@font-face{font-family: "Font";\nsrc: url("font.ttf");\nfont-weight: normal;font-style: normal}a{}',
         [