svgdotjs / svg.js

The lightweight library for manipulating and animating SVG
https://svgjs.dev
Other
11.01k stars 1.07k forks source link

Issues importing existing SVG #1173

Closed HenrySkup closed 11 months ago

HenrySkup commented 3 years ago

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_

okwme commented 3 years ago

same

Fuzzyma commented 11 months ago

cant reproduce