@wordpress/dom-ready 4.37.1-next.ba3aee3a2.0 → 4.37.1-next.v.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.
- package/package.json +2 -2
- package/src/test/index.test.ts +12 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/dom-ready",
|
|
3
|
-
"version": "4.37.1-next.
|
|
3
|
+
"version": "4.37.1-next.v.0+500f87dd8",
|
|
4
4
|
"description": "Execute callback after the DOM is loaded.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "ca0db0ee8ac2116cd307650136027d26d0cdd9bd"
|
|
51
51
|
}
|
package/src/test/index.test.ts
CHANGED
|
@@ -4,18 +4,13 @@
|
|
|
4
4
|
import domReady from '../';
|
|
5
5
|
|
|
6
6
|
describe( 'domReady', () => {
|
|
7
|
-
beforeAll( () => {
|
|
8
|
-
Object.defineProperty( document, 'readyState', {
|
|
9
|
-
value: 'loading',
|
|
10
|
-
writable: true,
|
|
11
|
-
} );
|
|
12
|
-
} );
|
|
13
|
-
|
|
14
7
|
describe( 'when document readystate is complete', () => {
|
|
15
8
|
it( 'should call the callback.', () => {
|
|
16
9
|
const callback = jest.fn( () => {} );
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
Object.defineProperty( document, 'readyState', {
|
|
11
|
+
get: () => 'complete',
|
|
12
|
+
configurable: true,
|
|
13
|
+
} );
|
|
19
14
|
domReady( callback );
|
|
20
15
|
expect( callback ).toHaveBeenCalled();
|
|
21
16
|
} );
|
|
@@ -24,8 +19,10 @@ describe( 'domReady', () => {
|
|
|
24
19
|
describe( 'when document readystate is interactive', () => {
|
|
25
20
|
it( 'should call the callback.', () => {
|
|
26
21
|
const callback = jest.fn( () => {} );
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
Object.defineProperty( document, 'readyState', {
|
|
23
|
+
get: () => 'interactive',
|
|
24
|
+
configurable: true,
|
|
25
|
+
} );
|
|
29
26
|
domReady( callback );
|
|
30
27
|
expect( callback ).toHaveBeenCalled();
|
|
31
28
|
} );
|
|
@@ -34,8 +31,10 @@ describe( 'domReady', () => {
|
|
|
34
31
|
describe( 'when document readystate is still loading', () => {
|
|
35
32
|
it( 'should add the callback as an event listener to the DOMContentLoaded event.', () => {
|
|
36
33
|
const addEventListener = jest.fn( () => {} );
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
Object.defineProperty( document, 'readyState', {
|
|
35
|
+
get: () => 'loading',
|
|
36
|
+
configurable: true,
|
|
37
|
+
} );
|
|
39
38
|
Object.defineProperty( document, 'addEventListener', {
|
|
40
39
|
value: addEventListener,
|
|
41
40
|
} );
|