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
I have a problem in IE where it throws WrongDocumentError while trying to replace the img element with the svg.
After looking into it, I found that other similar packages solved this same problem with a simple solution:
// Fix for browser (IE, maybe other too) which are throwing 'WrongDocumentError'// if you replace an element which is not in the documentif(document.importNode){injectElem=document.importNode(injectElem,true);}
I tried it myself by adding it right before:
// Replace img element with new element. This is the actual injection.parentNode.replaceChild(injectElem,imgElem);
And it fixed the issue 👍
Any thoughts on this?
Thanks!
The text was updated successfully, but these errors were encountered:
The documentation for Document.importNode() says that it creates a clone of the node is created. A similar method seems to be Document.adoptNode(), which moves the node from the original document to the new one without creating a clone. Maybe this is more appropriate for our purpose?
Can you try if using Document.adoptNode() solves the issue?
So the problem is happening on IE 11. I don't have a way to test it in older IE versions, sorry about that.
The only thing I think I'm doing differently is that the SVG injection happens inside an iframe.
I also confirm that Document.adoptNode() also seems to work:
// Fix for browser (IE, maybe other too) which are throwing 'WrongDocumentError'// if you replace an element which is not in the documentif(document.adoptNode){injectElem=document.adoptNode(injectElem);}
Hi!
Firstly, thank you for your work!
I have a problem in IE where it throws
WrongDocumentError
while trying to replace the img element with the svg.After looking into it, I found that other similar packages solved this same problem with a simple solution:
I tried it myself by adding it right before:
And it fixed the issue 👍
Any thoughts on this?
Thanks!
The text was updated successfully, but these errors were encountered: