Refixes #648 - apply at-rule support.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Mon, 24 Aug 2015 04:36:18 +0000 (05:36 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Mon, 24 Aug 2015 04:36:18 +0000 (05:36 +0100)
We were not trimming the token before checking for @ character so
only rules without whitespace were working fine.

lib/tokenizer/extract-properties.js
test/integration-test.js
test/tokenizer/tokenizer-test.js

index 83d9005..2548449 100644 (file)
@@ -63,7 +63,7 @@ function extractProperties(string, selectors, context) {
     var candidate = candidates[i];
     var firstColonAt = candidate.indexOf(':');
 
-    var atRule = candidate[0] == '@';
+    var atRule = candidate.trim()[0] == '@';
     if (atRule) {
       context.track(candidate);
       list.push([AT_RULE, candidate.trim()]);
index 0e3d605..7212901 100644 (file)
@@ -2167,6 +2167,10 @@ vows.describe('integration tests')
       'multiple @apply with some styling': [
         'a{@apply(--rule1);@apply(--rule2);color:red;display:block}',
         'a{@apply(--rule1);@apply(--rule2);color:red;display:block}'
+      ],
+      'multiple @apply with whitespace': [
+        'a{' + lineBreak + '@apply(--rule1);' + lineBreak + '  @apply(--rule2);' + lineBreak + 'color:red;display:block}',
+        'a{@apply(--rule1);@apply(--rule2);color:red;display:block}'
       ]
     })
   )
index 1ae2863..ca44bc0 100644 (file)
@@ -180,6 +180,16 @@ vows.describe(tokenize)
           ]
         ]
       ],
+      '@apply with whitespace': [
+        'a{  @apply(--rule); }',
+        [
+          [
+            'selector',
+            [['a']],
+            [['at-rule', '@apply(--rule)']]
+          ]
+        ]
+      ],
       'media query': [
         '@media (min-width:980px){}',
         [