Fixes #939 - semicolon after `@apply` at rule.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Wed, 10 May 2017 08:45:45 +0000 (10:45 +0200)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Wed, 10 May 2017 17:42:15 +0000 (19:42 +0200)
Why:

* Apparently IE11 and Edge doesn't like `@apply` without a trailing
  semicolon.

History.md
lib/writer/helpers.js
test/integration-test.js

index 7e642a3..bee3cd7 100644 (file)
@@ -1,6 +1,7 @@
 [4.1.2 / 2017-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v4.1.1...4.1)
 ==================
 
+* Fixed issue [#939](https://github.com/jakubpawlowicz/clean-css/issues/939) - semicolon after `@apply` at rule.
 * Fixed issue [#940](https://github.com/jakubpawlowicz/clean-css/issues/940) - handling more `font` keywords.
 * Fixed issue [#941](https://github.com/jakubpawlowicz/clean-css/issues/941) - breaking up vendor prefixed `animation`.
 
index 0b8999e..ab08633 100644 (file)
@@ -85,7 +85,7 @@ function property(context, tokens, position, lastPropertyAt) {
   switch (token[0]) {
     case Token.AT_RULE:
       store(context, token);
-      store(context, position < lastPropertyAt ? semicolon(context, Breaks.AfterProperty, false) : emptyCharacter);
+      store(context, semicolon(context, Breaks.AfterProperty, false));
       break;
     case Token.COMMENT:
       store(context, token);
index cf0b575..0130e31 100644 (file)
@@ -2108,14 +2108,14 @@ vows.describe('integration tests')
     }, { inline: 'none' })
   )
   .addBatch(
-    optimizerContext('body at-rules', {
+    optimizerContext('@apply', {
       'single @apply': [
-        'a{@apply(--rule)}',
-        'a{@apply(--rule)}'
+        'a{@apply(--rule);}',
+        'a{@apply(--rule);}'
       ],
       'multiple @apply': [
-        'a{@apply(--rule1);@apply(--rule2)}',
-        'a{@apply(--rule1);@apply(--rule2)}'
+        'a{@apply(--rule1);@apply(--rule2);}',
+        'a{@apply(--rule1);@apply(--rule2);}'
       ],
       'multiple @apply with some styling': [
         'a{@apply(--rule1);@apply(--rule2);color:red;display:block}',
@@ -2126,8 +2126,8 @@ vows.describe('integration tests')
         'a{@apply(--rule1);@apply(--rule2);color:red;display:block}'
       ],
       '@apply another rule within :root context': [
-        ':root{--layout:{display:flex};--layout-horizontal:{@apply(--layout)};}',
-        ':root{--layout:{display:flex};--layout-horizontal:{@apply(--layout)};}'
+        ':root{--layout:{display:flex};--layout-horizontal:{@apply(--layout);};}',
+        ':root{--layout:{display:flex};--layout-horizontal:{@apply(--layout);};}'
       ]
     })
   )