Skip to content

fix(removeUnknownsAndDefaults): skip if attr used in css selector #2144

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

Merged
merged 1 commit into from
Jun 21, 2025

Conversation

SethFalco
Copy link
Member

@SethFalco SethFalco commented Jun 21, 2025

The removeUnknownsAndDefaults plugin was removing attributes that were used in CSS selectors, which is problematic because that breaks styles!

We should be checking if that attribute is used as part of an attribute selector before we commit to removing it.

I've implemented it to only check for the existence of an attribute selector that references the key, rather than actually compare the value, because attribute selectors are complicated. For example:

  • [preserveAspectRatio]
  • [preserveAspectRatio=]
  • [preserveAspectRatio^="x"]
  • etc…

In future, we can explore making a more robust utility. But for now, let's at least not break SVGs.

Related

@SethFalco SethFalco merged commit bc49deb into svg:main Jun 21, 2025
14 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.

1 participant