svgdotjs / svgdom

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

Change getRootNode to get the DOCUMENT_NODE itself, not one of its children #92

Closed HenrySwanson closed 2 years ago

HenrySwanson commented 2 years ago

I'm having the same issue as #87, where <use> elements cannot be transformed, but I think this fix applies more broadly.

The snippet they've provided also gives an error:

Error: Getting bbox of element "g" is not possible: TypeError: node.getRootNode(...).getElementById is not a function

I am not particularly familiar with how the browser model works, but this function was returning the element right below DOCUMENT_NODE, and not the DOCUMENT_NODE itself, and that seems incorrect to me.

Applying this change fixed the error I was getting, so hopefully this is right :)

Fuzzyma commented 2 years ago

Thx for your contribution! The fix is correct but at the won't spot. What you changed is the bundled file but it should be changed in the source. Can you apply the fix to the source files please? :)

HenrySwanson commented 2 years ago

I wasn't kidding when I said I'm not familiar with webdev... 🙃

I made the change in src/dom/Node.js, ran webpack without arguments, and it produced the appropriate change in main-require.cjs.

Fuzzyma commented 2 years ago

Awesome, thank you :)

pgmillon commented 1 year ago

Hi, any chance to get that released ? I have the very same issue and would love a small bugfix release :)