Support for css variables
See original GitHub issueThe following is an example of parsing (and using) custom css properties (aka variables):
var parser = new StylesheetParser();
var stylesheet = parser.Parse(@"
:root {
--my-color: rgb(147, 30, 45);
}
a {
color: var(--my-color);
}
");
var c = stylesheet.StyleRules.First(sr => sr.SelectorText == "a").Style.Color;
I would expect the value to be "rgb(147, 30, 45)" or at the very least "var(--my-color)". Today it is the empty string.
Likewise I would expect I could get the value of any css property including custom ones such as the above like this:
stylesheet.StyleRules.First(sr => sr.SelectorText == ":root").Style.GetPropertyValue("--my-color");
Today that also yields the empty string instead of the expected "rgb(147, 30, 45)".
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
CSS Variables (Custom Properties) | Can I use... Support ...
CSS Variables (Custom Properties). - CR. Permits the declaration and usage of cascading variables in stylesheets. Usage % of. all users, all tracked ......
Read more >Using CSS custom properties (variables) - MDN Web Docs
Custom properties (sometimes referred to as CSS variables or cascading variables) are entities defined by CSS authors that contain specific ...
Read more >Browser Compatibility of CSS Variables (Custom Properties)
CSS Variables (Custom Properties) on Safari is fully supported on 10-16.4, partially supported on 9.1-9.1, and not supported on 3.2-9 Safari versions. CSS ......
Read more >A user's guide to CSS variables – Increment: Frontend
CSS variables are currently supported for 93 percent of users globally. CSS variables are currently supported for 93 percent of users globally. If...
Read more >A Strategy Guide To CSS Custom Properties
CSS Custom Properties (sometimes known as 'CSS variables') are now supported in all modern browsers, and people are starting to use them in ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Did this ever get implemented? I’m looking to parse CSS variables today. 😃
It’s in the works but not completed yet. Pull requests are welcome, however.