wp/wp-includes/js/dist/dom-ready.js
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
    80 /******/ 	// __webpack_public_path__
    80 /******/ 	// __webpack_public_path__
    81 /******/ 	__webpack_require__.p = "";
    81 /******/ 	__webpack_require__.p = "";
    82 /******/
    82 /******/
    83 /******/
    83 /******/
    84 /******/ 	// Load entry module and return exports
    84 /******/ 	// Load entry module and return exports
    85 /******/ 	return __webpack_require__(__webpack_require__.s = 340);
    85 /******/ 	return __webpack_require__(__webpack_require__.s = 419);
    86 /******/ })
    86 /******/ })
    87 /************************************************************************/
    87 /************************************************************************/
    88 /******/ ({
    88 /******/ ({
    89 
    89 
    90 /***/ 340:
    90 /***/ 419:
    91 /***/ (function(module, __webpack_exports__, __webpack_require__) {
    91 /***/ (function(module, __webpack_exports__, __webpack_require__) {
    92 
    92 
    93 "use strict";
    93 "use strict";
    94 __webpack_require__.r(__webpack_exports__);
    94 __webpack_require__.r(__webpack_exports__);
       
    95 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return domReady; });
       
    96 /**
       
    97  * @typedef {() => void} Callback
       
    98  *
       
    99  * TODO: Remove this typedef and inline `() => void` type.
       
   100  *
       
   101  * This typedef is used so that a descriptive type is provided in our
       
   102  * automatically generated documentation.
       
   103  *
       
   104  * An in-line type `() => void` would be preferable, but the generated
       
   105  * documentation is `null` in that case.
       
   106  *
       
   107  * @see https://github.com/WordPress/gutenberg/issues/18045
       
   108  */
       
   109 
    95 /**
   110 /**
    96  * Specify a function to execute when the DOM is fully loaded.
   111  * Specify a function to execute when the DOM is fully loaded.
    97  *
   112  *
    98  * @param {Function} callback A function to execute after the DOM is ready.
   113  * @param {Callback} callback A function to execute after the DOM is ready.
    99  *
   114  *
   100  * @example
   115  * @example
   101  * ```js
   116  * ```js
   102  * import domReady from '@wordpress/dom-ready';
   117  * import domReady from '@wordpress/dom-ready';
   103  *
   118  *
   106  * } );
   121  * } );
   107  * ```
   122  * ```
   108  *
   123  *
   109  * @return {void}
   124  * @return {void}
   110  */
   125  */
   111 var domReady = function domReady(callback) {
   126 function domReady(callback) {
   112   if (document.readyState === 'complete' || // DOMContentLoaded + Images/Styles/etc loaded, so we call directly.
   127   if (document.readyState === 'complete' || // DOMContentLoaded + Images/Styles/etc loaded, so we call directly.
   113   document.readyState === 'interactive' // DOMContentLoaded fires at this point, so we call directly.
   128   document.readyState === 'interactive' // DOMContentLoaded fires at this point, so we call directly.
   114   ) {
   129   ) {
   115       return callback();
   130       return void callback();
   116     } // DOMContentLoaded has not fired yet, delay callback until then.
   131     } // DOMContentLoaded has not fired yet, delay callback until then.
   117 
   132 
   118 
   133 
   119   document.addEventListener('DOMContentLoaded', callback);
   134   document.addEventListener('DOMContentLoaded', callback);
   120 };
   135 }
   121 
       
   122 /* harmony default export */ __webpack_exports__["default"] = (domReady);
       
   123 
   136 
   124 
   137 
   125 /***/ })
   138 /***/ })
   126 
   139 
   127 /******/ })["default"];
   140 /******/ })["default"];