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

You readme say you support @media definition, but it's looks like you don't #5

Closed MoOx closed 9 years ago

MoOx commented 9 years ago

Input

:root { --fontSize: 2em; }
.Section { font-size: var(--fontSize); }

@media (min-width: 64em) {
  :root { --font-size: 3em; }
}

Output

.Section { font-size: 2em; }

This is totally unexpected. I expect in a way, to have a font-size corresponding to the definition in the media query.

tunnckoCore commented 9 years ago

erm.. totally expected. custom property --font-size isn't defined anywhere, so it use var(--fontSize) -> 2em.

MoOx commented 9 years ago

According to spec, it's a wrong behavior. Please this example on Firefox (which support custom props) with a viewport > 64em and one < 64em. You will understand my concern.

MadLittleMods commented 9 years ago

The output is as expected. --fontSize !== --font-size

To get what you expect/desire, try this:

:root { --fontSize: 2em; }
.Section { font-size: var(--fontSize); }

@media (min-width: 64em) {
  :root { --fontSize: 3em; }
}
MoOx commented 9 years ago

My bad for this :)

tunnckoCore commented 9 years ago

The output is as expected. --fontSize !== --font-size

exactly.