flobacher / SVGInjector2

Fast, caching, dynamic inline SVG DOM injection library
MIT License
57 stars 8 forks source link

SVGInjector messes up id's inside defs #15

Open yiotaz opened 7 years ago

yiotaz commented 7 years ago

This is a reference issue, since the old version seems a bit abandoned. https://github.com/iconic/SVGInjector/issues/29

Can you help me sort this out? I can send you my svg file if it will help somehow.

flobacher commented 7 years ago

Hi, do you still have this issue, and if, does it happen with svginjector2 or with the original version? Since the original issue seems to be resolved, I would like to close this too.. thx!

gebeer commented 6 years ago

I hate to say that we are having exactly the same issue here with v2.1.3

gebeer commented 6 years ago

As a temp workaround for our use case I uncommented https://github.com/flobacher/SVGInjector2/blob/master/src/svg-injector.js#L390 This helped

flobacher commented 6 years ago

@gebeer could you please provide a sample so I can reproduce this? thank you!

gebeer commented 6 years ago

@flobacher I setup a test to reconfirm the issue. But in the isolated test context it won't happen. The problem only appears to happen in IE11/Edge where clip-path ids are incorrect. In the svg folder of the test repo are the original svg and the injected versions. One injected with Firefox, one with Edge. If you compare those, you will see that for the Edge version, the clipPath IDs inside get appended a '-0' while the clip-path attributes further down are lacking that '-0' Example Edge: L. 17 inside : <clipPath id="clip-path-2-0"> L.365 : <g clip-path="url(&quot;#clip-path-2&quot;)">

In the Firefox version the '-0' gets appended correctly also in L365

Here's how the problematic SVG looks in original context in Edge: image

Hope this is of any help. Unfortunately I can't supply a live non-working example.

flobacher commented 6 years ago

@gebeer thank you for that example! I will try to take a look. I must apologize if it takes a bit of time, but I only do this in my spare time and my timely-ressources are limited. I would be more than happy to accept a PR ofc =) Also I experienced something similar once with Edge 14, but with 16 the issue went away..