Skip to content

Commit

Permalink
Fixes #780 - space after inlined variables.
Browse files Browse the repository at this point in the history
Let's not assume variables are functions to stay. Polymer inlines
variables so removing a space after a variable can break styling.
  • Loading branch information
jakubpawlowicz committed Jun 1, 2016
1 parent 04a587f commit 1d8069c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions History.md
Expand Up @@ -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)
==================
Expand Down
6 changes: 1 addition & 5 deletions lib/stringifier/helpers.js
Expand Up @@ -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;
}
Expand All @@ -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) ||
Expand Down
6 changes: 5 additions & 1 deletion test/integration-test.js
Expand Up @@ -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}',
Expand All @@ -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}'
]
})
)
Expand Down

0 comments on commit 1d8069c

Please sign in to comment.