Fixes #874 - regression in at-rule tokenization.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Thu, 26 Jan 2017 13:35:42 +0000 (14:35 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Thu, 26 Jan 2017 13:49:55 +0000 (14:49 +0100)
Why:

* Another case after #872 where at-rules were incorrectly
  tokenized because `propertyToken` wasn't reset.

History.md
lib/tokenizer/tokenize.js
test/tokenizer/tokenize-test.js

index 9a0153c..7f644f8 100644 (file)
@@ -1,3 +1,8 @@
+[4.0.2 / 2017-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v4.0.1...4.0)
+==================
+
+* Fixed issue [#874](https://github.com/jakubpawlowicz/clean-css/issues/874) - regression in at-rule tokenization.
+
 [4.0.1 / 2017-01-25](https://github.com/jakubpawlowicz/clean-css/compare/v4.0.0...v4.0.1)
 ==================
 
index c3ff4f4..acb2448 100644 (file)
@@ -242,6 +242,7 @@ function intoTokens(source, externalContext, internalContext, isNested) {
       buffer = [];
     } else if (character == Marker.SEMICOLON && level == Level.RULE && propertyToken && buffer.length === 0) {
       // semicolon after bracketed value at rule level, e.g. a{color:rgb(...);<--
+      propertyToken = null;
       seekingValue = false;
     } else if (character == Marker.SEMICOLON && level == Level.RULE && buffer.length > 0 && buffer[0] == Marker.AT) {
       // semicolon for at-rule at rule level, e.g. a{@apply(--variable);<--
index 2b4cff5..dfc6757 100644 (file)
@@ -1688,6 +1688,49 @@ vows.describe(tokenize)
           ]
         ]
       ],
+      '@apply after a function': [
+        '.block{color:rgb(0,0,0);@apply(--test)}',
+        [
+          [
+            'rule',
+            [
+              [
+                'rule-scope',
+                '.block',
+                [
+                  [1, 0, undefined]
+                ]
+              ]
+            ],
+            [
+              [
+                'property',
+                [
+                  'property-name',
+                  'color',
+                  [
+                    [1, 7, undefined]
+                  ]
+                ],
+                [
+                  'property-value',
+                  'rgb(0,0,0)',
+                  [
+                    [1, 13, undefined]
+                  ]
+                ]
+              ],
+              [
+                'at-rule',
+                '@apply(--test)',
+                [
+                  [1, 24, undefined]
+                ]
+              ]
+            ]
+          ]
+        ]
+      ],
       'media query': [
         '@media (min-width:980px){}',
         [