kollapsminoriteten/wp-includes/js/dist/dom-ready.js

76 lines
2.4 KiB
JavaScript
Raw Normal View History

2024-04-17 11:32:24 +02:00
/******/ (() => { // webpackBootstrap
2022-06-16 14:03:35 +02:00
/******/ "use strict";
/******/ // The require scope
/******/ var __webpack_require__ = {};
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
2024-04-17 11:32:24 +02:00
/******/ (() => {
2022-06-16 14:03:35 +02:00
/******/ // define getter functions for harmony exports
2024-04-17 11:32:24 +02:00
/******/ __webpack_require__.d = (exports, definition) => {
2022-06-16 14:03:35 +02:00
/******/ 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] });
/******/ }
/******/ }
2019-11-02 10:38:58 +01:00
/******/ };
2024-04-17 11:32:24 +02:00
/******/ })();
2022-06-16 14:03:35 +02:00
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
2024-04-17 11:32:24 +02:00
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
2022-06-16 14:03:35 +02:00
/******/
2019-11-02 10:38:58 +01:00
/************************************************************************/
2022-06-16 14:03:35 +02:00
var __webpack_exports__ = {};
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
2024-04-17 11:32:24 +02:00
/* harmony export */ "default": () => (/* binding */ domReady)
2022-06-16 14:03:35 +02:00
/* harmony export */ });
2020-05-06 17:23:38 +02:00
/**
* @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
*/
2019-11-02 10:38:58 +01:00
/**
* Specify a function to execute when the DOM is fully loaded.
*
2020-05-06 17:23:38 +02:00
* @param {Callback} callback A function to execute after the DOM is ready.
2019-11-02 10:38:58 +01:00
*
* @example
* ```js
* import domReady from '@wordpress/dom-ready';
*
* domReady( function() {
* //do something after DOM loads.
* } );
* ```
*
* @return {void}
*/
2020-05-06 17:23:38 +02:00
function domReady(callback) {
2021-07-23 11:58:50 +02:00
if (typeof document === 'undefined') {
return;
}
2023-12-07 09:44:11 +01:00
if (document.readyState === 'complete' ||
// DOMContentLoaded + Images/Styles/etc loaded, so we call directly.
2019-11-02 10:38:58 +01:00
document.readyState === 'interactive' // DOMContentLoaded fires at this point, so we call directly.
) {
2022-04-02 10:26:41 +02:00
return void callback();
2023-12-07 09:44:11 +01:00
}
2019-11-02 10:38:58 +01:00
2023-12-07 09:44:11 +01:00
// DOMContentLoaded has not fired yet, delay callback until then.
2019-11-02 10:38:58 +01:00
document.addEventListener('DOMContentLoaded', callback);
2020-05-06 17:23:38 +02:00
}
2019-11-02 10:38:58 +01:00
2022-06-16 14:03:35 +02:00
(window.wp = window.wp || {}).domReady = __webpack_exports__["default"];
/******/ })()
;