diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 07:56:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 07:56:49 +0000 |
commit | a415c29efee45520ae252d2aa28f1083a521cd7b (patch) | |
tree | f4ade4b6668ecc0765de7e1424f7c1427ad433ff /wp-includes/js/dist/dom-ready.js | |
parent | Initial commit. (diff) | |
download | wordpress-a415c29efee45520ae252d2aa28f1083a521cd7b.tar.xz wordpress-a415c29efee45520ae252d2aa28f1083a521cd7b.zip |
Adding upstream version 6.4.3+dfsg1.upstream/6.4.3+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'wp-includes/js/dist/dom-ready.js')
-rw-r--r-- | wp-includes/js/dist/dom-ready.js | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/wp-includes/js/dist/dom-ready.js b/wp-includes/js/dist/dom-ready.js new file mode 100644 index 0000000..37b8aa7 --- /dev/null +++ b/wp-includes/js/dist/dom-ready.js @@ -0,0 +1,76 @@ +/******/ (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"]; +/******/ })() +;
\ No newline at end of file |