MadLittleMods / postcss-css-variables

PostCSS plugin to transform CSS Custom Properties(CSS variables) syntax into a static representation
https://madlittlemods.github.io/postcss-css-variables/playground/
Other
536 stars 62 forks source link

Resolve nested `var` in fallback #37

Closed asvny closed 7 years ago

asvny commented 8 years ago

Just a spec clarification , are we allowed to refer fallback as another var ie var(--color-2) from root

:root {
 --color-1:red;
 --color-2:green;
}

.Component {
  background: var(--color-10,var(--color-2))
}

I expect output to be

.Component {
  background: green
}

but the current output is

.Component {
  background: var(--color-2)
}
MadLittleMods commented 8 years ago

Sorry for the slight delay. According to the spec, it looks like this should work but I can see that postcss-css-variables doesn't substitute it properly at the moment.

if the var() function has a fallback value as its second argument, replace the var() function by the fallback value. If there are any var() references in the fallback, substitute them as well.

https://drafts.csswg.org/css-variables/#using-variables

Feel free to make a PR :grinning:

asvny commented 8 years ago

@MadLittleMods I have made a pull request .. please review and then accept ... thank u !

MadLittleMods commented 7 years ago

Merged via https://github.com/MadLittleMods/postcss-css-variables/commit/d2bea891e34acd1bd2b655983db44186c3b0db55

MadLittleMods commented 7 years ago

Published in v0.7.0 https://github.com/MadLittleMods/postcss-css-variables/blob/master/CHANGELOG.md#v070---2017-3-12 (also on npm)

Thanks @asvny and @marklu for the contributions 😍