Skip to content

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

Merged
capricorn86 merged 7 commits into
capricorn86:masterfrom
odanado:fix/1363
Apr 5, 2024
Merged

fix: [#1363] Fix bug with missing fallback value#1381
capricorn86 merged 7 commits into
capricorn86:masterfrom
odanado:fix/1363

Conversation

@odanado

@odanado odanado commented Apr 4, 2024

Copy link
Copy Markdown
Contributor

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 requested a review from capricorn86 as a code owner April 4, 2024 13:11
@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

@capricorn86 capricorn86 left a comment

Copy link
Copy Markdown
Owner

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