Skip to content

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

Merged
SethFalco merged 1 commit intosvg:mainfrom
SethFalco:skip-attr-selectors-remove-defaults
Jun 21, 2025
Merged

fix(removeUnknownsAndDefaults): skip if attr used in css selector#2144
SethFalco merged 1 commit intosvg:mainfrom
SethFalco:skip-attr-selectors-remove-defaults

Conversation

@SethFalco
Copy link
Copy Markdown
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