-
Notifications
You must be signed in to change notification settings - Fork 144
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
SVGInjector messes up id's inside defs #29
Comments
Hey Thomas! SVGInjector renumerates all of the SVG IRI addressable elements to avoid an issue with browser render engines when using multiple instances of the same SVG. Take a look at: So, in your case, the element in your SVG that's using the Could you share that SVG (or the smallest version of it that exhibits the issue) and I'll look into what's is going on. Thanks! |
Thanks @protodave, that actually makes a lot of sense. Unfortunately that breaks my css which is styling an element in |
While I understand the benefits of the 'name-spacing' you're doing by changing ID names, I just want to add my actual use case where the defs are predefined in the injected SVG and the elements using these defs are inserted later via javascript. This creates the same not-insurmountable problem as @tbredin which is perfectly fine in the context of Iconic but becomes a small issue in the wider use of SVGinjector. It might be a good idea to have the scope of IRI renaming revealed as an option in future versions if there's more than a few lone voices calling for it. |
I have the exact same issue. I have a radialGradient with an id where it is targeted throughout the svg file as a fill attribute with this id. How can I make this work? |
Can you please tell me if you have found a solution for this? How do I need to reconstruct my svg in order to work properly? |
For those in need, you need to modify the JS source of SVGInjector to exclude certain defs included by default. Check the var Modify it by commenting out what you don't want messed with, ensuring that your ID's are unique across your project, as I'm sure you already do. For example:
|
Something else I need to ask you is this: I have this In Chrome it works perfectly fine. Chrome is as if it takes into account each svg instance separately and searches the id in that one, thus we have the result we want, unlike Firefox. Thank you |
Yeah, FireFox is weird when it comes to SVG. Without the code you're using it's hard to identify the bug, but there are a few relatively common ones. StackOverflow is your friend here 😉 My own tips are:
|
Thank you very much for your time and advice. Much appreciate it :) |
I had issue in SVG loading by svg-injector ver 1.1.3. So, followed this solution but now SVG's colors aren't displaying correctly. |
The index of the injected svg seems to be inserted after id's, which is breaking url references
eg:
fill: url(#green)
image.svg:
But when injected:
The text was updated successfully, but these errors were encountered: