WordPress/wp-includes/js/dist/dom-ready.js
gziolo 2ec4c366e6 Build: Update webpack to v5.x
Update webpack version to latest version https://www.npmjs.com/package/webpack. This aligns closer with how the Gutenberg plugin handles WordPress packages. Related update in Gutenberg from August 2021: https://github.com/WordPress/gutenberg/pull/33818.

Props walbo, desrosj, mukesh27.
Fixes #51750.



Built from https://develop.svn.wordpress.org/trunk@53135


git-svn-id: http://core.svn.wordpress.org/trunk@52724 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-11 12:04:30 +00:00

76 lines
2.5 KiB
JavaScript

/******/ (function() { // webpackBootstrap
/******/ "use strict";
/******/ // The require scope
/******/ var __webpack_require__ = {};
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
/******/ !function() {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = function(exports, definition) {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ }();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ !function() {
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
/******/ }();
/******/
/************************************************************************/
var __webpack_exports__ = {};
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* binding */ domReady; }
/* harmony export */ });
/**
* @typedef {() => void} Callback
*
* TODO: Remove this typedef and inline `() => void` type.
*
* This typedef is used so that a descriptive type is provided in our
* automatically generated documentation.
*
* An in-line type `() => void` would be preferable, but the generated
* documentation is `null` in that case.
*
* @see https://github.com/WordPress/gutenberg/issues/18045
*/
/**
* Specify a function to execute when the DOM is fully loaded.
*
* @param {Callback} 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}
*/
function domReady(callback) {
if (typeof document === 'undefined') {
return;
}
if (document.readyState === 'complete' || // DOMContentLoaded + Images/Styles/etc loaded, so we call directly.
document.readyState === 'interactive' // DOMContentLoaded fires at this point, so we call directly.
) {
return void callback();
} // DOMContentLoaded has not fired yet, delay callback until then.
document.addEventListener('DOMContentLoaded', callback);
}
(window.wp = window.wp || {}).domReady = __webpack_exports__["default"];
/******/ })()
;