@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/dom-ready",
3
- "version": "4.37.1-next.ba3aee3a2.0",
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": "67d2e486fcd40c753591cf911ca0659132f519ca"
50
+ "gitHead": "ca0db0ee8ac2116cd307650136027d26d0cdd9bd"
51
51
  }
@@ -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
- // @ts-expect-error document.readyState is read-only
18
- document.readyState = 'complete';
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
- // @ts-expect-error document.readyState is read-only
28
- document.readyState = 'interactive';
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
- // @ts-expect-error document.readyState is read-only
38
- document.readyState = 'loading';
34
+ Object.defineProperty( document, 'readyState', {
35
+ get: () => 'loading',
36
+ configurable: true,
37
+ } );
39
38
  Object.defineProperty( document, 'addEventListener', {
40
39
  value: addEventListener,
41
40
  } );