Open fortinmike opened 2 years ago
Oh and by the way I also added a .nvmrc
file because the svg-inject
gulp task fails on recent node.js versions. I hope that's OK. I did not do further tests to see which maximum version of node.js svg-inject works with, but node.js 10.5.0 is fine. Feel free to change that to a more appropriate version.
Great! Works on my app.
Problem
svg-inject does not add suffixes to IDs located in style elements; it only replaces
url(#id)
references. This breaks styles and animations such as those exported by SVGator due to "standalone" IDs not being suffixed, when themakeIdsUnique
option is enabled.Fix
Replace the regex for id replacements in the style element with a more generalized one that matches
#id
as well asurl(#id)
(as before).Although this is a much more generalized regex, as far as I know this shouldn't cause issues with fancy CSS syntax.
Example
Original SVG
After injection with unfixed svg-inject
Styles stay exactly the same after injection, disconnecting styles from the now-suffixed elements in the SVG body.
After injection with this pull request