Fixes #780 - space after inlined variables.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Wed, 1 Jun 2016 07:00:28 +0000 (09:00 +0200)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Wed, 1 Jun 2016 09:19:13 +0000 (11:19 +0200)
Let's not assume variables are functions to stay. Polymer inlines
variables so removing a space after a variable can break styling.

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

index 7c6cd74..07658eb 100644 (file)
@@ -7,6 +7,7 @@
 ==================
 
 * Fixed issue [#779](https://github.com/jakubpawlowicz/clean-css/issues/779) - merging `background-(position|size)`.
+* Fixed issue [#780](https://github.com/jakubpawlowicz/clean-css/issues/780) - space after inlined variables.
 
 [3.4.14 / 2016-05-31](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.13...v3.4.14)
 ==================
index 5e9f117..d3f4abe 100644 (file)
@@ -16,10 +16,6 @@ function supportsAfterClosingBrace(token) {
   return token[0][0] == 'background' || token[0][0] == 'transform' || token[0][0] == 'src';
 }
 
-function isVariable(token, valueIndex) {
-  return token[valueIndex][0].indexOf('var(') === 0;
-}
-
 function afterClosingBrace(token, valueIndex) {
   return token[valueIndex][0][token[valueIndex][0].length - 1] == ')' || token[valueIndex][0].indexOf('__ESCAPED_URL_CLEAN_CSS') === 0;
 }
@@ -45,7 +41,7 @@ function inFilter(token) {
 }
 
 function inSpecialContext(token, valueIndex, context) {
-  return (!context.spaceAfterClosingBrace && supportsAfterClosingBrace(token) || isVariable(token, valueIndex)) && afterClosingBrace(token, valueIndex) ||
+  return !context.spaceAfterClosingBrace && supportsAfterClosingBrace(token) && afterClosingBrace(token, valueIndex) ||
     beforeSlash(token, valueIndex) ||
     afterSlash(token, valueIndex) ||
     beforeComma(token, valueIndex) ||
index efc240e..419fb05 100644 (file)
@@ -2649,7 +2649,7 @@ vows.describe('integration tests')
       ],
       'all values': [
         'a{--width:1px;--style:solid;--color:#000}.one{border:var(--width)var(--style)var(--color)}',
-        'a{--width:1px;--style:solid;--color:#000}.one{border:var(--width)var(--style)var(--color)}'
+        'a{--width:1px;--style:solid;--color:#000}.one{border:var(--width) var(--style) var(--color)}'
       ],
       'Polymer mixins - simple optimizations': [
         'a{ display:block; --my-toolbar: { color:#f00; width:96px }; color:blue}',
@@ -2666,6 +2666,10 @@ vows.describe('integration tests')
       'Polymer mixins - not fitting into a single chunk of 128 bytes': [
         ':host{--live-head-theme: { line-height: 40px !important; vertical-align: middle; background: transparent; height: 40px; z-index: 999; }; }',
         ':host{--live-head-theme:{line-height:40px!important;vertical-align:middle;background:0 0;height:40px;z-index:999};}'
+      ],
+      'Polymer mixins - inlined variables': [
+        '.spinner{-webkit-animation:container-rotate var(--paper-spinner-container-rotation-duration) linear infinite}',
+        '.spinner{-webkit-animation:container-rotate var(--paper-spinner-container-rotation-duration) linear infinite}'
       ]
     })
   )