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

Upgrade to JSDOM@11 #4770

Merged
merged 3 commits into from
Oct 26, 2017
Merged

Upgrade to JSDOM@11 #4770

merged 3 commits into from
Oct 26, 2017

Conversation

SimenB
Copy link
Member

@SimenB SimenB commented Oct 26, 2017

Summary
Now that we've dropped node 4, we can finally do this

Test plan
Green CI

@@ -22,13 +22,14 @@ class JSDOMEnvironment {
errorEventListener: ?Function;
moduleMocker: ?ModuleMocker;

constructor(config: ProjectConfig): void {
constructor(config: ProjectConfig) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flow knows this

@@ -44,7 +44,6 @@
"istanbul-lib-coverage": "^1.0.0",
"jasmine-reporters": "^2.2.0",
"jquery": "^3.2.1",
"jsdom": "^9.12.0",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason for it to be specified down here as well?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope I guess, workspaces should handle this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, it's hoisted, and I didn't see any require of it outside of jest-environment-jsdom

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it works, that's fine. We used to have a test depending on jsdom, but that was all pre workspaces.

@cpojer cpojer merged commit cfbda80 into jestjs:master Oct 26, 2017
@cpojer
Copy link
Member

cpojer commented Oct 26, 2017

@SimenB thanks for updating. It's been a long time coming!

url: config.testURL,
});
const global = (this.global = this.document.defaultView);
const global = (this.global = this.document.window.document.defaultView);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, why do this?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see, this.document is no longer a document, it's a JSDOM instance. That's pretty confusing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which part is confusing? Should this.document be renamed to this.jsdomInstance? I have to admit I floundered a bit here

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you shouldn't name a JSDOM instance document (similar to how you shouldn't name it birthdayCake).

We use the variable name dom for short in the JSDOM docs.

@Zirro
Copy link

Zirro commented Oct 27, 2017

A note of caution - this particular version of jsdom (11.3.0) includes an SVG-related regression. While it is a spec-compliance improvement (creating instances of Element instead of HTMLUnknownElement outside of the HTML namespace), it has the side-effect of SVG elements missing common properties such as style, since jsdom has had no real SVG support.

There is a new pull request which is about to change this by implementing proper SVG support - jsdom/jsdom#2011 - and it'll be part of the next jsdom release. Since jsdom is a spare time project for everyone involved it is not yet certain when this release will happen, though presumably within the next few weeks.

In case the next major Jest release is scheduled to happen soon, I figured I'd make you aware of this. Using 11.2.0 instead might be an option if that's the case. Besides this, it's great to see Jest moving to recent versions of jsdom.

@SimenB
Copy link
Member Author

SimenB commented Oct 27, 2017

I think we already hit that, fixed in #4645

@Zirro
Copy link

Zirro commented Oct 27, 2017

@SimenB Hmm, isn't that fix only related to a formatter? The described issue will affect anyone trying to use SVG elements in a jsdom environment.

@SimenB
Copy link
Member Author

SimenB commented Oct 28, 2017

Ah, good point. I'm not sure when 22 of Jest is scheduled, might make sense to lock it down to 11.2, then. Thanks for pointing it out!

(also waiting for jsdom/jsdom#1994 to be merged as well, so we can remove the implementation here)

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants