diff --git a/bin/update-readmes.js b/bin/update-readmes.js index da84d066eef75..f40eee3d8129e 100755 --- a/bin/update-readmes.js +++ b/bin/update-readmes.js @@ -16,7 +16,7 @@ const packages = [ //'date', //'deprecated', 'dom', - //'dom-ready', + 'dom-ready', 'e2e-test-utils', //'edit-post', 'element', diff --git a/packages/dom-ready/README.md b/packages/dom-ready/README.md index c262e04a93a62..0c8515e57f3b1 100644 --- a/packages/dom-ready/README.md +++ b/packages/dom-ready/README.md @@ -12,9 +12,19 @@ npm install @wordpress/dom-ready --save _This package assumes that your code will run in an **ES2015+** environment. If you're using an environment that has limited or no support for ES2015+ such as lower versions of IE then using [core-js](https://github.com/zloirock/core-js) or [@babel/polyfill](https://babeljs.io/docs/en/next/babel-polyfill) will add support for these methods. Learn more about it in [Babel docs](https://babeljs.io/docs/en/next/caveats)._ -### Usage +## API -```JS + + +### default + +[src/index.js#L29-L29](src/index.js#L29-L29) + +Specify a function to execute when the DOM is fully loaded. + +**Usage** + +```js import domReady from '@wordpress/dom-ready'; domReady( function() { @@ -22,8 +32,19 @@ domReady( function() { } ); ``` +**Parameters** + +- **callback** `Function`: A function to execute after the DOM is ready. + +**Returns** + +`void`: + + + + ## Browser support -See https://make.wordpress.org/design/handbook/design-guide/browser-support/ +See

Code is Poetry.

diff --git a/packages/dom-ready/src/index.js b/packages/dom-ready/src/index.js index f19b862e0e28c..82c0ed781d5e1 100644 --- a/packages/dom-ready/src/index.js +++ b/packages/dom-ready/src/index.js @@ -3,6 +3,15 @@ * * @param {Function} callback A function to execute after the DOM is ready. * + * @example + * ```js + * import domReady from '@wordpress/dom-ready'; + * + * domReady( function() { + * //do something after DOM loads. + * } ); + * ``` + * * @return {void} */ const domReady = function( callback ) {