w0rm / gulp-svgstore

Combine svg files into one with symbol elements
https://www.npmjs.com/package/gulp-svgstore
645 stars 33 forks source link

Transfer svg presentation attributes to a wrapping g element #110

Closed tomasklaen closed 2 years ago

tomasklaen commented 2 years ago

107 became too annoying to deal with manually, so here's a PR.

If a style or any other presentation attributes are detected on a main <svg> element, the content of a symbol will be wrapped in <g> and those attributes transferred to it.

List of presentation attributes taken from: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/Presentation

w0rm commented 2 years ago

Sorry for spamming you with notifications. I was thinking to use Set instead of Array for presentationAttributes, but in the end I came up with an idea to loop through presentationAttributes and deleted my other comments.

And thanks again for taking time to implement this feature.

w0rm commented 2 years ago

@tomasklaen thanks, will release shortly. I will make it a major version bump because folks could be relying on the implicit attribute cleanup.

tomasklaen commented 2 years ago

Yeah that's wise. The new behavior will definitely cause some icons to now have hardcoded colors, since previously all fill attributes on svg were being dropped.