@wordpress/dom-ready 4.36.1-next.8fd3f8831.0 → 4.37.1-next.06ee73755.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/LICENSE.md +1 -1
- package/README.md +1 -5
- package/build/index.cjs +1 -1
- package/build/index.cjs.map +3 -3
- package/build-module/{index.js → index.mjs} +2 -2
- package/build-module/index.mjs.map +7 -0
- package/build-types/index.d.ts +2 -27
- package/build-types/index.d.ts.map +1 -1
- package/package.json +4 -5
- package/src/{index.js → index.ts} +2 -18
- package/src/test/{index.test.js → index.test.ts} +12 -10
- package/build-module/index.js.map +0 -7
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -32,11 +32,7 @@ domReady( function () {
|
|
|
32
32
|
|
|
33
33
|
_Parameters_
|
|
34
34
|
|
|
35
|
-
- _callback_ `
|
|
36
|
-
|
|
37
|
-
_Returns_
|
|
38
|
-
|
|
39
|
-
- `void`:
|
|
35
|
+
- _callback_ `VoidFunction`: A function to execute after the DOM is ready.
|
|
40
36
|
|
|
41
37
|
<!-- END TOKEN(Autogenerated API docs) -->
|
|
42
38
|
|
package/build/index.cjs
CHANGED
|
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// packages/dom-ready/src/index.
|
|
20
|
+
// packages/dom-ready/src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
default: () => domReady
|
package/build/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/index.
|
|
4
|
-
"sourcesContent": ["/**\n *
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Specify a function to execute when the DOM is fully loaded.\n *\n * @param callback A function to execute after the DOM is ready.\n *\n * @example\n * ```js\n * import domReady from '@wordpress/dom-ready';\n *\n * domReady( function() {\n * \t//do something after DOM loads.\n * } );\n * ```\n */\nexport default function domReady( callback: VoidFunction ) {\n\tif ( typeof document === 'undefined' ) {\n\t\treturn;\n\t}\n\n\tif (\n\t\tdocument.readyState === 'complete' || // DOMContentLoaded + Images/Styles/etc loaded, so we call directly.\n\t\tdocument.readyState === 'interactive' // DOMContentLoaded fires at this point, so we call directly.\n\t) {\n\t\treturn void callback();\n\t}\n\n\t// DOMContentLoaded has not fired yet, delay callback until then.\n\tdocument.addEventListener( 'DOMContentLoaded', callback );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAce,SAAR,SAA2B,UAAyB;AAC1D,MAAK,OAAO,aAAa,aAAc;AACtC;AAAA,EACD;AAEA,MACC,SAAS,eAAe;AAAA,EACxB,SAAS,eAAe,eACvB;AACD,WAAO,KAAK,SAAS;AAAA,EACtB;AAGA,WAAS,iBAAkB,oBAAoB,QAAS;AACzD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// packages/dom-ready/src/index.
|
|
1
|
+
// packages/dom-ready/src/index.ts
|
|
2
2
|
function domReady(callback) {
|
|
3
3
|
if (typeof document === "undefined") {
|
|
4
4
|
return;
|
|
@@ -12,4 +12,4 @@ function domReady(callback) {
|
|
|
12
12
|
export {
|
|
13
13
|
domReady as default
|
|
14
14
|
};
|
|
15
|
-
//# sourceMappingURL=index.
|
|
15
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Specify a function to execute when the DOM is fully loaded.\n *\n * @param callback A function to execute after the DOM is ready.\n *\n * @example\n * ```js\n * import domReady from '@wordpress/dom-ready';\n *\n * domReady( function() {\n * \t//do something after DOM loads.\n * } );\n * ```\n */\nexport default function domReady( callback: VoidFunction ) {\n\tif ( typeof document === 'undefined' ) {\n\t\treturn;\n\t}\n\n\tif (\n\t\tdocument.readyState === 'complete' || // DOMContentLoaded + Images/Styles/etc loaded, so we call directly.\n\t\tdocument.readyState === 'interactive' // DOMContentLoaded fires at this point, so we call directly.\n\t) {\n\t\treturn void callback();\n\t}\n\n\t// DOMContentLoaded has not fired yet, delay callback until then.\n\tdocument.addEventListener( 'DOMContentLoaded', callback );\n}\n"],
|
|
5
|
+
"mappings": ";AAce,SAAR,SAA2B,UAAyB;AAC1D,MAAK,OAAO,aAAa,aAAc;AACtC;AAAA,EACD;AAEA,MACC,SAAS,eAAe;AAAA,EACxB,SAAS,eAAe,eACvB;AACD,WAAO,KAAK,SAAS;AAAA,EACtB;AAGA,WAAS,iBAAkB,oBAAoB,QAAS;AACzD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build-types/index.d.ts
CHANGED
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {() => void} Callback
|
|
3
|
-
*
|
|
4
|
-
* TODO: Remove this typedef and inline `() => void` type.
|
|
5
|
-
*
|
|
6
|
-
* This typedef is used so that a descriptive type is provided in our
|
|
7
|
-
* automatically generated documentation.
|
|
8
|
-
*
|
|
9
|
-
* An in-line type `() => void` would be preferable, but the generated
|
|
10
|
-
* documentation is `null` in that case.
|
|
11
|
-
*
|
|
12
|
-
* @see https://github.com/WordPress/gutenberg/issues/18045
|
|
13
|
-
*/
|
|
14
1
|
/**
|
|
15
2
|
* Specify a function to execute when the DOM is fully loaded.
|
|
16
3
|
*
|
|
17
|
-
* @param
|
|
4
|
+
* @param callback A function to execute after the DOM is ready.
|
|
18
5
|
*
|
|
19
6
|
* @example
|
|
20
7
|
* ```js
|
|
@@ -24,18 +11,6 @@
|
|
|
24
11
|
* //do something after DOM loads.
|
|
25
12
|
* } );
|
|
26
13
|
* ```
|
|
27
|
-
*
|
|
28
|
-
* @return {void}
|
|
29
|
-
*/
|
|
30
|
-
export default function domReady(callback: Callback): void;
|
|
31
|
-
/**
|
|
32
|
-
* TODO: Remove this typedef and inline `() => void` type.
|
|
33
|
-
*
|
|
34
|
-
* This typedef is used so that a descriptive type is provided in our
|
|
35
|
-
* automatically generated documentation.
|
|
36
|
-
*
|
|
37
|
-
* An in-line type `() => void` would be preferable, but the generated
|
|
38
|
-
* documentation is `null` in that case.
|
|
39
14
|
*/
|
|
40
|
-
export
|
|
15
|
+
export default function domReady(callback: VoidFunction): undefined;
|
|
41
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAE,QAAQ,EAAE,YAAY,aAcvD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/dom-ready",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.37.1-next.06ee73755.0",
|
|
4
4
|
"description": "Execute callback after the DOM is loaded.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -29,13 +29,12 @@
|
|
|
29
29
|
"build-types",
|
|
30
30
|
"*.md"
|
|
31
31
|
],
|
|
32
|
-
"type": "module",
|
|
33
32
|
"main": "build/index.cjs",
|
|
34
|
-
"module": "build-module/index.
|
|
33
|
+
"module": "build-module/index.mjs",
|
|
35
34
|
"exports": {
|
|
36
35
|
".": {
|
|
37
36
|
"types": "./build-types/index.d.ts",
|
|
38
|
-
"import": "./build-module/index.
|
|
37
|
+
"import": "./build-module/index.mjs",
|
|
39
38
|
"require": "./build/index.cjs"
|
|
40
39
|
},
|
|
41
40
|
"./package.json": "./package.json"
|
|
@@ -48,5 +47,5 @@
|
|
|
48
47
|
"publishConfig": {
|
|
49
48
|
"access": "public"
|
|
50
49
|
},
|
|
51
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "fd315436f44683a993d5f053789b5279d95b2872"
|
|
52
51
|
}
|
|
@@ -1,21 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {() => void} Callback
|
|
3
|
-
*
|
|
4
|
-
* TODO: Remove this typedef and inline `() => void` type.
|
|
5
|
-
*
|
|
6
|
-
* This typedef is used so that a descriptive type is provided in our
|
|
7
|
-
* automatically generated documentation.
|
|
8
|
-
*
|
|
9
|
-
* An in-line type `() => void` would be preferable, but the generated
|
|
10
|
-
* documentation is `null` in that case.
|
|
11
|
-
*
|
|
12
|
-
* @see https://github.com/WordPress/gutenberg/issues/18045
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
1
|
/**
|
|
16
2
|
* Specify a function to execute when the DOM is fully loaded.
|
|
17
3
|
*
|
|
18
|
-
* @param
|
|
4
|
+
* @param callback A function to execute after the DOM is ready.
|
|
19
5
|
*
|
|
20
6
|
* @example
|
|
21
7
|
* ```js
|
|
@@ -25,10 +11,8 @@
|
|
|
25
11
|
* //do something after DOM loads.
|
|
26
12
|
* } );
|
|
27
13
|
* ```
|
|
28
|
-
*
|
|
29
|
-
* @return {void}
|
|
30
14
|
*/
|
|
31
|
-
export default function domReady( callback ) {
|
|
15
|
+
export default function domReady( callback: VoidFunction ) {
|
|
32
16
|
if ( typeof document === 'undefined' ) {
|
|
33
17
|
return;
|
|
34
18
|
}
|
|
@@ -4,17 +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
|
-
|
|
10
|
+
Object.defineProperty( document, 'readyState', {
|
|
11
|
+
get: () => 'complete',
|
|
12
|
+
configurable: true,
|
|
13
|
+
} );
|
|
18
14
|
domReady( callback );
|
|
19
15
|
expect( callback ).toHaveBeenCalled();
|
|
20
16
|
} );
|
|
@@ -23,7 +19,10 @@ describe( 'domReady', () => {
|
|
|
23
19
|
describe( 'when document readystate is interactive', () => {
|
|
24
20
|
it( 'should call the callback.', () => {
|
|
25
21
|
const callback = jest.fn( () => {} );
|
|
26
|
-
|
|
22
|
+
Object.defineProperty( document, 'readyState', {
|
|
23
|
+
get: () => 'interactive',
|
|
24
|
+
configurable: true,
|
|
25
|
+
} );
|
|
27
26
|
domReady( callback );
|
|
28
27
|
expect( callback ).toHaveBeenCalled();
|
|
29
28
|
} );
|
|
@@ -32,7 +31,10 @@ describe( 'domReady', () => {
|
|
|
32
31
|
describe( 'when document readystate is still loading', () => {
|
|
33
32
|
it( 'should add the callback as an event listener to the DOMContentLoaded event.', () => {
|
|
34
33
|
const addEventListener = jest.fn( () => {} );
|
|
35
|
-
|
|
34
|
+
Object.defineProperty( document, 'readyState', {
|
|
35
|
+
get: () => 'loading',
|
|
36
|
+
configurable: true,
|
|
37
|
+
} );
|
|
36
38
|
Object.defineProperty( document, 'addEventListener', {
|
|
37
39
|
value: addEventListener,
|
|
38
40
|
} );
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * @typedef {() => void} Callback\n *\n * TODO: Remove this typedef and inline `() => void` type.\n *\n * This typedef is used so that a descriptive type is provided in our\n * automatically generated documentation.\n *\n * An in-line type `() => void` would be preferable, but the generated\n * documentation is `null` in that case.\n *\n * @see https://github.com/WordPress/gutenberg/issues/18045\n */\n\n/**\n * Specify a function to execute when the DOM is fully loaded.\n *\n * @param {Callback} callback A function to execute after the DOM is ready.\n *\n * @example\n * ```js\n * import domReady from '@wordpress/dom-ready';\n *\n * domReady( function() {\n * \t//do something after DOM loads.\n * } );\n * ```\n *\n * @return {void}\n */\nexport default function domReady( callback ) {\n\tif ( typeof document === 'undefined' ) {\n\t\treturn;\n\t}\n\n\tif (\n\t\tdocument.readyState === 'complete' || // DOMContentLoaded + Images/Styles/etc loaded, so we call directly.\n\t\tdocument.readyState === 'interactive' // DOMContentLoaded fires at this point, so we call directly.\n\t) {\n\t\treturn void callback();\n\t}\n\n\t// DOMContentLoaded has not fired yet, delay callback until then.\n\tdocument.addEventListener( 'DOMContentLoaded', callback );\n}\n"],
|
|
5
|
-
"mappings": ";AA8Be,SAAR,SAA2B,UAAW;AAC5C,MAAK,OAAO,aAAa,aAAc;AACtC;AAAA,EACD;AAEA,MACC,SAAS,eAAe;AAAA,EACxB,SAAS,eAAe,eACvB;AACD,WAAO,KAAK,SAAS;AAAA,EACtB;AAGA,WAAS,iBAAkB,oBAAoB,QAAS;AACzD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|