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

Add removeAttributesBySelector plugin #929

Merged
merged 2 commits into from
Feb 24, 2019
Merged

Conversation

bmease
Copy link
Contributor

@bmease bmease commented Mar 24, 2018

This pull request adds the removeAttributesBySelector plugin. Allowing the removal of attributes in elements found by a css selector.

For a project I'm currently working on, I need to remove the attribute fill only if it has the value #00ff00. The removeAttrs plugin only queries the element name and is not able to meet this need.

I'm happy to add other plugins like addAttributesBySelector, or refactor removeAttrs, or create another plugin that combines all this functionality. For now, I've just left it as a separate plugin.

plugins:
  - removeAttributesBySelector:
    selector: "[fill='#00ff00']"
    attributes: "fill"

<rect x="0" y="0" width="100" height="100" fill="#00ff00" />
  ↓
<rect x="0" y="0" width="100" height="100"/>

bmease added 2 commits March 24, 2018 22:25
Removes attributes of elements that match a css selector.

- Add plugin
- Change config file to use plugin
- Update README
- Add tests
@Herman-Freund
Copy link

#977 Addresses the same issue utilizing the existing plugin.

However, The plugin proposed in this PR has an extra benefit of being able to remove a different attribute than the one matching the selector.

@GreLI GreLI merged commit b4bd5d5 into svg:master Feb 24, 2019
@GreLI
Copy link
Member

GreLI commented Feb 24, 2019

SVGO v1.2.0 has been just released!

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