svg.js icon indicating copy to clipboard operation
svg.js copied to clipboard

Issues importing existing SVG

Open HenrySkup opened this issue 5 years ago • 1 comments

Hi, I'm facing the same issue as below:

when doing:

let svgstr = "<svg ... ";
const draw = SVG();
draw.svg(svgstr);

I get Uncaught (in promise) TypeError: Cannot read property 'nodeName' of null

I am hitting a bug with the existing release in importing SVG. When I call:

const otherSvg = SVG().svg(svgString);

I get a null reference exception in the parent function:

  parent (type) {
    if (this.isRoot()) {
      return this.node.parentNode.nodeName === '#document'
        ? null
        : adopt(this.node.parentNode)
    }

This function is called from the svg function which imports the svg data from a string.

I tested building my own and it appears this issue has already been fixed (and the relevant functions are fairly different.). Can anyone suggest a workaround to this in the meantime? Am I creating the SVG object incorrectly?

_Originally posted by @BrianHanechak in

https://github.com/svgdotjs/svg.js/issues/1152#issuecomment-715032602_

HenrySkup avatar Dec 07 '20 09:12 HenrySkup

same

okwme avatar Apr 16 '21 19:04 okwme

cant reproduce

Fuzzyma avatar Sep 03 '23 08:09 Fuzzyma