I have an svg tag that has <use>
element inside it.
The use loads an SVG from some path:
div.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%">
<use xlink:href="${href}" href="${href}" /></svg>`
(Please note it's a string since it's being used for a customElement shadow template).
What I need is a way to detect a 404 on the <use>
element in case the href is incorrect.
I tried putting an onerror="()=>{...}"
attribute, but it's not being called.
Wrapping the with a try/catch block did not help either.
Can anyone please help? Thanks!