-
Notifications
You must be signed in to change notification settings - Fork 61
Cascading vars: Plugin works correctly? Or browsers do not work correctly? #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Or is this an incorrect example? And need next <div class='block theme'>
Blue
<h1 class='block__title'>
Red in plugin, but blue in spec
</h1>
</div> :root { --color: red }
.theme { --color: blue }
.block,
.block__title {
color: var(--color)
} |
Thanks for noticing. I think it is an incorrect example, https://github.com/MadLittleMods/postcss-css-variables/blob/a817fb90a23eb9dbf7b3848583b67e0299250c3e/README.md#caveats and Your second example, #78 (comment) compiles as expected (all red btw) because we only take into account explicit relationships. We can simplify the example to the following (feel free to create a PR) <div class="block theme-blue">
Red in plugin, but blue in spec
</div>
|
@MadLittleMods PR Ready :) #79 |
Thanks for the PR @belozer. From my extra digging, I think we just need to change everything to ✔️ I looked some more info to verify and CSS custom properties do inherit, https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables#Inheritance_of_CSS_Variables ❌ The problem with the example is the nesting of
We can update the example to be the following, <div class="component">
Black
<div class="title">
Blue
<div class="decoration">
Green
<div class="title">Blue with this plugin, but green per spec</div>
</div>
</div>
</div> .component {
--text-color: blue;
}
.component .title {
color: var(--text-color);
}
.component .decoration {
--text-color: green;
color: var(--text-color);
} |
I'am not found specs with examples abount cascading vars. But try this case https://github.com/MadLittleMods/postcss-css-variables#caveats native in Browser on CodePen. (without plugin)
It turns out that the plugin works correctly? Or browsers do not work correctly?
The text was updated successfully, but these errors were encountered: