svgdom
svgdom copied to clipboard
href vs xlink:href issue in bboxUtils.js
I got an (node:3708) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'slice' of null
error for this SVG fragment:
<use xlink:href="#SVGID_1_" style="overflow:visible;"/>
I tracked it down to this code in line 57:
let ref = node.getAttribute('href')
Quickly changing it to let ref = node.getAttribute('href') || node.getAttribute('xlink:href')
made it work for my case. I'm not familiar enough to suggest this as a general fix, but perhaps somebody more familiar with the meaning behind "href" and "xlink:href" could take a look at this?
Jeah, namespaces... thats a thing :D. Can you please post the code which led to the call of getAttribute
?
It was a call to .getBBox()
on an svg element that contained an element with a xlink:href="..."
property.