Skip to content

feat: resolve css variables #2

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

Closed
wants to merge 3 commits into from
Closed

Conversation

paviad
Copy link

@paviad paviad commented Dec 14, 2024

Current style sheet logic ignores CSS variables, and can break when parsing them.

This PR properly resolves CSS variables.

@denighte
Copy link

denighte commented Mar 27, 2025

Hi @paviad, thank you very much for your idea and contribution, but unfortuantely we had to fix it differently than you did, since your code does not take into account a lot of cases. Also we decided to not use regex because of performance concerns. Here is some of the missed cases:

  1. Shorthands resolving
  2. Several var() expression in one css statement e.g. 1px var(--style) var(--color)
  3. Complex defaults handling and neted vars, e.g. var(--test, var(--another, 'black'))
  4. Cyclic references, e.g. --one: var(--two); --two: var(--one)
  5. Validation handling, e.g. word-break: var(--incorrect) should log a message that css declaration can't be resolved
    And other more minor stuff
    You can see all the changes in the following commit: 75380e906f718e34613ff3d63da44ce0738cde7e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants