svgdom icon indicating copy to clipboard operation
svgdom copied to clipboard

href vs xlink:href issue in bboxUtils.js

Open killroy42 opened this issue 4 years ago • 2 comments

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?

killroy42 avatar Mar 06 '20 11:03 killroy42

Jeah, namespaces... thats a thing :D. Can you please post the code which led to the call of getAttribute?

Fuzzyma avatar Mar 07 '20 02:03 Fuzzyma

It was a call to .getBBox() on an svg element that contained an element with a xlink:href="..." property.

killroy42 avatar Mar 09 '20 13:03 killroy42