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

Selectively remove matched style/attr #1165

Closed
wants to merge 1 commit into from

Conversation

strarsis
Copy link
Contributor

This PR adds options to removeMatchedSelectors option for selectively removing style and/or attr.
This can be useful if the attrs should be kept for selecting or styling with pseudo-classes (e.g. :hover).

@TrySound
Copy link
Member

Hi @strarsis. I don't get what "attr" does here. Is this still relevant?

@strarsis
Copy link
Contributor Author

@TrySound: This PR adds optional sub-options to the removeMatchedSelectors option which allow finer control:
Should styles be kept after inlining?
Should attributes (id or class currently) be removed after the matching styles have been applied?
Especially the second option can be useful, e.g. styling parts of a SVG using its classes after inlining the styles.

@SethFalco
Copy link
Member

SethFalco commented Sep 8, 2024

This shouldn't be necessary anymore.

The problem this is solving has been address by:

TL;DR: Added a helper includesAttrSelector, which checks if an ID/class/attribute it used by a CSS selector. If so, we won't remove it.

Feel free to share an SVG if you can still reproduce scenarios where we're removing attributes too eagerly. However, in theory it should be possible for us to even drop the removeMatchedSelectors option entirely now I think. 🤔

@SethFalco SethFalco closed this Sep 8, 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.

3 participants