Add support for SVGElement?
Opened this issue · 2 comments
The jsdom package appears to support SVGElement now. Can support for SVGElement be added to jsdom-global?
Thanks!
Thanks for responding. I am using the latest version of jsdom, 18.1.1, which was released 15 days ago.
And jsdom does appear to have support for SVGElement. While non-existent in the source, presumably because it is generated, there is a file named SVGElement.js in node_modules\jsdom\lib\jsdom\living\generated. Not sure what that file gets generated from.
It appears to me that the problem is caused by jsdom-global's keys.js file's LIVING_KEYS array missing SVGElement. If I add SVGElement to the array, my error message goes away. Just noticed I didn't provide the error message.
The error message is "ReferenceError: SVGElement is not defined"
While adding "SVGElement" to the LIVING_KEYS array makes the error message go away, I'm not completely sure that alone is a proper fix because I don't know what all needs to be done for SVGElement to be properly supported. I'm just Forrest Gumping my way through this.
I have worked around this by adding the following line of code to a module that gets run for all my tests:
global.SVGElement = window.SVGElement;
I've seen someone online propose this as a work-around and it does remove the error message but I feel like my work-around is better.
global.SVGElement = global.Element;
But I'm hoping jsdom-global will be updated to properly support SVGElement by adding the LIVING_KEYS entry and updating anything else needed. Also, if this is done, there's a comment right above the LIVING_KEYS array that is no longer correct.
Thanks.