question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for css variables

See original GitHub issue

The 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:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Webreapercommented, Oct 8, 2021

Did this ever get implemented? I’m looking to parse CSS variables today. 😃

0reactions
TylerBrinkscommented, Oct 17, 2021

It’s in the works but not completed yet. Pull requests are welcome, however.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found