You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the above is run through grunt-svgstore, the linearGradient ids are all made unique, but url references within fill remain the same. So the gradient wouldn't work in the final SVG.
Here's a really crude fix that I added to my local version of svgstore.js
// Make fill attributes with ID references unique$('[fill]').each(function(){var$elem=$(this);varfill=$elem.attr('fill');// pull out if no url reference specifiedif(fill.indexOf('url(')<0)return;varfillRegex=fill.match(/\((.*)\)/);varurlReference=fillRegex[1];// pull out if not an ID referenceif(urlReference.charAt(0)!=='#')return;// get the id by namevarid=urlReference.slice(1,urlReference.length);// set the new unique id reference$elem.attr('fill','url(#'+uniqueId+id+')');});
The above isn't perfect, but it works. It only trawls through elements with fill attributes, but there could be other attributes that contain url(#id) style references. I'm not too sure what they are though.
Hopefully you can add in something like that so that the final SVG output makes ALL IDs unique, rather than just a few.
Cheers
The text was updated successfully, but these errors were encountered:
Hey thanks for this awesome task. It's a real time saver!
So there's just a small issue where IDs within url references don't get handled, which breaks references within the final SVG output.
Here's an example:
When the above is run through grunt-svgstore, the
linearGradient
ids are all made unique, but url references withinfill
remain the same. So the gradient wouldn't work in the final SVG.Here's a really crude fix that I added to my local version of
svgstore.js
The above isn't perfect, but it works. It only trawls through elements with
fill
attributes, but there could be other attributes that containurl(#id)
style references. I'm not too sure what they are though.Hopefully you can add in something like that so that the final SVG output makes ALL IDs unique, rather than just a few.
Cheers
The text was updated successfully, but these errors were encountered: