svgdotjs / svgdom

Straightforward DOM implementation to make SVG.js run headless on Node.js
MIT License
265 stars 53 forks source link

href vs xlink:href issue in bboxUtils.js #55

Open killroy42 opened 4 years ago

killroy42 commented 4 years ago

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?

Fuzzyma commented 4 years ago

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

killroy42 commented 4 years ago

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