jest-environment-jsdom 27.2.4 → 27.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/build/index.js +27 -18
  2. package/package.json +13 -10
package/build/index.js CHANGED
@@ -68,22 +68,27 @@ class JSDOMEnvironment {
68
68
 
69
69
  _defineProperty(this, 'moduleMocker', void 0);
70
70
 
71
- this.dom = new (_jsdom().JSDOM)('<!DOCTYPE html>', {
72
- pretendToBeVisual: true,
73
- resources:
74
- typeof config.testEnvironmentOptions.userAgent === 'string'
75
- ? new (_jsdom().ResourceLoader)({
76
- userAgent: config.testEnvironmentOptions.userAgent
77
- })
78
- : undefined,
79
- runScripts: 'dangerously',
80
- url: config.testURL,
81
- virtualConsole: new (_jsdom().VirtualConsole)().sendTo(
82
- (options === null || options === void 0 ? void 0 : options.console) ||
83
- console
84
- ),
85
- ...config.testEnvironmentOptions
86
- });
71
+ this.dom = new (_jsdom().JSDOM)(
72
+ typeof config.testEnvironmentOptions.html === 'string'
73
+ ? config.testEnvironmentOptions.html
74
+ : '<!DOCTYPE html>',
75
+ {
76
+ pretendToBeVisual: true,
77
+ resources:
78
+ typeof config.testEnvironmentOptions.userAgent === 'string'
79
+ ? new (_jsdom().ResourceLoader)({
80
+ userAgent: config.testEnvironmentOptions.userAgent
81
+ })
82
+ : undefined,
83
+ runScripts: 'dangerously',
84
+ url: config.testURL,
85
+ virtualConsole: new (_jsdom().VirtualConsole)().sendTo(
86
+ (options === null || options === void 0 ? void 0 : options.console) ||
87
+ console
88
+ ),
89
+ ...config.testEnvironmentOptions
90
+ }
91
+ );
87
92
  const global = (this.global = this.dom.window.document.defaultView);
88
93
 
89
94
  if (!global) {
@@ -158,12 +163,16 @@ class JSDOMEnvironment {
158
163
  if (this.global) {
159
164
  if (this.errorEventListener) {
160
165
  this.global.removeEventListener('error', this.errorEventListener);
161
- } // Dispose "document" to prevent "load" event from triggering.
166
+ }
167
+
168
+ this.global.close(); // Dispose "document" to prevent "load" event from triggering.
169
+ // Note that this.global.close() will trigger the CustomElement::disconnectedCallback
170
+ // Do not reset the document before CustomElement disconnectedCallback function has finished running,
171
+ // document should be accessible within disconnectedCallback.
162
172
 
163
173
  Object.defineProperty(this.global, 'document', {
164
174
  value: null
165
175
  });
166
- this.global.close();
167
176
  }
168
177
 
169
178
  this.errorEventListener = null; // @ts-expect-error
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jest-environment-jsdom",
3
- "version": "27.2.4",
3
+ "version": "27.4.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/facebook/jest.git",
@@ -10,21 +10,24 @@
10
10
  "main": "./build/index.js",
11
11
  "types": "./build/index.d.ts",
12
12
  "exports": {
13
- ".": "./build/index.js",
13
+ ".": {
14
+ "types": "./build/index.d.ts",
15
+ "default": "./build/index.js"
16
+ },
14
17
  "./package.json": "./package.json"
15
18
  },
16
19
  "dependencies": {
17
- "@jest/environment": "^27.2.4",
18
- "@jest/fake-timers": "^27.2.4",
19
- "@jest/types": "^27.2.4",
20
+ "@jest/environment": "^27.4.0",
21
+ "@jest/fake-timers": "^27.4.0",
22
+ "@jest/types": "^27.4.0",
23
+ "@types/jsdom": "^16.2.4",
20
24
  "@types/node": "*",
21
- "jest-mock": "^27.2.4",
22
- "jest-util": "^27.2.4",
25
+ "jest-mock": "^27.4.0",
26
+ "jest-util": "^27.4.0",
23
27
  "jsdom": "^16.6.0"
24
28
  },
25
29
  "devDependencies": {
26
- "@jest/test-utils": "^27.2.4",
27
- "@types/jsdom": "^16.2.4"
30
+ "@jest/test-utils": "^27.4.0"
28
31
  },
29
32
  "engines": {
30
33
  "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0"
@@ -32,5 +35,5 @@
32
35
  "publishConfig": {
33
36
  "access": "public"
34
37
  },
35
- "gitHead": "5886f6c4d681aa9fc9bfc2517efd2b7f6035a4cd"
38
+ "gitHead": "0dc6dde296550370ade2574d6665748fed37f9c9"
36
39
  }