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 polyfill in combination with unused CSS variable removal #17555

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

philipp-spiess
Copy link
Member

@philipp-spiess philipp-spiess commented Apr 4, 2025

This PR fixes an issue we noticed while investigating #17553, where the unused CSS variable removal didn't work properly when the theme variable it tried to remove was modified by a polyfill rule.

The way the bookkeeping for the unused CSS variable worked was that it tired to find the declaration inside it's parent after the traversal. However, the color-mix(…) polyfill has since then made changes to the declaration so it can't find it's position correctly anymore and will thus instead delete the last declaration of the node (this caused unrelated CSS variables to be eliminated while the ones with color-mix(…) were unexpectedly kept).

To fix this, we decided to apply the polyfills after any eventual deletions. This also ensures that no @supports query for the variables are created and simplifies the code a bit since all polyfills are now colocated.

Test plan

@philipp-spiess philipp-spiess force-pushed the fix/color-mix-var-removal branch from 352e77f to b93750a Compare April 4, 2025 14:13
@philipp-spiess philipp-spiess marked this pull request as ready for review April 6, 2025 23:58
@philipp-spiess philipp-spiess requested a review from a team as a code owner April 6, 2025 23:58
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.

1 participant