Skip to content
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

fix: [#1363] Fix bug with missing fallback value #1381

Merged
merged 7 commits into from
Apr 5, 2024

Conversation

odanado
Copy link
Contributor

@odanado odanado commented Apr 4, 2024

Close #1363

Custom properties without fallback values can be converted to custom properties with fallback values (using SINGLE_CSS_VARIABLE_REGEXP).

e.g.

  • var(--known)
    • In this case, you can resolve the value of the custom property by examining the value of --known.
  • var(--unknown, var(--known)
    • This case can be converted to a custom property with a fallback value of the form var(--unknown, known-color) by resolving the --known value.
  • var(--unknown, var(--unknown, var(--known)))
    • This case can also be converted to a custom property with a fallback value of the form var(--unknown, var(--unknown, known-color)) by resolving the value of --known.

After converting to a custom property for which a fallback value exists, the value can be found using a regular expression that handles the custom property in this case (using CSS_VARIABLE_REGEXP).

@odanado odanado marked this pull request as draft April 4, 2024 14:20
@odanado odanado marked this pull request as ready for review April 5, 2024 15:19
Copy link
Owner

@capricorn86 capricorn86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution @odanado! ⭐

I simplified the solution a bit by fixing the original RegExp, which will only require one white loop.

@capricorn86 capricorn86 merged commit a026261 into capricorn86:master Apr 5, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect return value of getPropertyValue for nested custom properties without fallback value
2 participants