antfu / drauu

Headless SVG-based drawboard in browser.
https://drauu.netlify.app/
MIT License
1.2k stars 64 forks source link

Dynamically created svg element not recognized due to case-sensitivity. #11

Closed unimplode closed 3 years ago

unimplode commented 3 years ago

When trying to mount to a dynamically created svg element (using document.createElement('svg'))`, I see the error:

index.mjs:576 Uncaught Error: [drauu] can only mount to a SVG element

It looks like the test for svg element only allows for lowercase tagName = 'svg', whereas a dynamically created svg element has upppercase tagName = 'SVG'.

Both uppercase and lowercase values for tagName do occur under different circumstances: (https://developer.mozilla.org/en-US/docs/Web/API/Element/tagName) so the check to see if the element is in fact an svg element might need to be refined.

It doesn't seem to be an issue for svg elements that are already defined in the html (i.e tagname is lowercase in that case).

antfu commented 3 years ago

Thanks for the info, PR Welcome!