Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SVGElement? #60

Open
joerattz opened this issue Dec 3, 2021 · 2 comments
Open

Add support for SVGElement? #60

joerattz opened this issue Dec 3, 2021 · 2 comments

Comments

@joerattz
Copy link

joerattz commented Dec 3, 2021

The jsdom package appears to support SVGElement now. Can support for SVGElement be added to jsdom-global?

Thanks!

@rstacruz
Copy link
Owner

rstacruz commented Dec 3, 2021 via email

@joerattz
Copy link
Author

joerattz commented Dec 6, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants