@wordpress/dom-ready 4.37.1-next.79a2f3cdd.0 → 4.37.1-next.ba3aee3a2.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/README.md CHANGED
@@ -32,11 +32,7 @@ domReady( function () {
32
32
 
33
33
  _Parameters_
34
34
 
35
- - _callback_ `Callback`: A function to execute after the DOM is ready.
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.js
20
+ // packages/dom-ready/src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  default: () => domReady
@@ -1,7 +1,7 @@
1
1
  {
2
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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;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;",
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.js
1
+ // packages/dom-ready/src/index.ts
2
2
  function domReady(callback) {
3
3
  if (typeof document === "undefined") {
4
4
  return;
@@ -1,7 +1,7 @@
1
1
  {
2
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;",
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
6
  "names": []
7
7
  }
@@ -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 {Callback} callback A function to execute after the DOM is ready.
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 type Callback = () => void;
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.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,2CAbW,QAAQ,GAWP,IAAI,CAgBf;;;;;;;;;;uBA3CY,MAAM,IAAI"}
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.37.1-next.79a2f3cdd.0",
3
+ "version": "4.37.1-next.ba3aee3a2.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",
@@ -47,5 +47,5 @@
47
47
  "publishConfig": {
48
48
  "access": "public"
49
49
  },
50
- "gitHead": "6a324496a37d9a333a11d4d7fe5fb93b8152a5ba"
50
+ "gitHead": "67d2e486fcd40c753591cf911ca0659132f519ca"
51
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 {Callback} callback A function to execute after the DOM is ready.
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
  }
@@ -14,6 +14,7 @@ describe( 'domReady', () => {
14
14
  describe( 'when document readystate is complete', () => {
15
15
  it( 'should call the callback.', () => {
16
16
  const callback = jest.fn( () => {} );
17
+ // @ts-expect-error document.readyState is read-only
17
18
  document.readyState = 'complete';
18
19
  domReady( callback );
19
20
  expect( callback ).toHaveBeenCalled();
@@ -23,6 +24,7 @@ describe( 'domReady', () => {
23
24
  describe( 'when document readystate is interactive', () => {
24
25
  it( 'should call the callback.', () => {
25
26
  const callback = jest.fn( () => {} );
27
+ // @ts-expect-error document.readyState is read-only
26
28
  document.readyState = 'interactive';
27
29
  domReady( callback );
28
30
  expect( callback ).toHaveBeenCalled();
@@ -32,6 +34,7 @@ describe( 'domReady', () => {
32
34
  describe( 'when document readystate is still loading', () => {
33
35
  it( 'should add the callback as an event listener to the DOMContentLoaded event.', () => {
34
36
  const addEventListener = jest.fn( () => {} );
37
+ // @ts-expect-error document.readyState is read-only
35
38
  document.readyState = 'loading';
36
39
  Object.defineProperty( document, 'addEventListener', {
37
40
  value: addEventListener,