@wordpress/dom-ready
Advanced tools
Comparing version 2.5.1 to 2.6.0
/** | ||
* @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 {Function} callback A function to execute after the DOM is ready. | ||
* @param {Callback} callback A function to execute after the DOM is ready. | ||
* | ||
@@ -17,7 +31,7 @@ * @example | ||
*/ | ||
var domReady = function domReady(callback) { | ||
export default function domReady(callback) { | ||
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 callback(); | ||
return void callback(); | ||
} // DOMContentLoaded has not fired yet, delay callback until then. | ||
@@ -27,5 +41,3 @@ | ||
document.addEventListener('DOMContentLoaded', callback); | ||
}; | ||
export default domReady; | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -6,8 +6,22 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
exports.default = domReady; | ||
/** | ||
* @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 {Function} callback A function to execute after the DOM is ready. | ||
* @param {Callback} callback A function to execute after the DOM is ready. | ||
* | ||
@@ -25,7 +39,7 @@ * @example | ||
*/ | ||
var domReady = function domReady(callback) { | ||
function domReady(callback) { | ||
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 callback(); | ||
return void callback(); | ||
} // DOMContentLoaded has not fired yet, delay callback until then. | ||
@@ -35,6 +49,3 @@ | ||
document.addEventListener('DOMContentLoaded', callback); | ||
}; | ||
var _default = domReady; | ||
exports.default = _default; | ||
} | ||
//# sourceMappingURL=index.js.map |
### WordPress - Web publishing software | ||
Copyright 2011-2019 by the contributors | ||
Copyright 2011-2020 by the contributors | ||
@@ -5,0 +5,0 @@ This program is free software; you can redistribute it and/or modify |
{ | ||
"name": "@wordpress/dom-ready", | ||
"version": "2.5.1", | ||
"version": "2.6.0", | ||
"description": "Execute callback after the DOM is loaded.", | ||
@@ -30,3 +30,3 @@ "author": "The WordPress Contributors", | ||
}, | ||
"gitHead": "707754784420a7089ae31ec4d6c756ce9af9c782" | ||
"gitHead": "3e867dd7c6560e4b2cb9a59cc02856e055be6142" | ||
} |
@@ -35,3 +35,3 @@ # DOM Ready | ||
- _callback_ `Function`: A function to execute after the DOM is ready. | ||
- _callback_ `Callback`: A function to execute after the DOM is ready. | ||
@@ -38,0 +38,0 @@ _Returns_ |
/** | ||
* @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 {Function} callback A function to execute after the DOM is ready. | ||
* @param {Callback} callback A function to execute after the DOM is ready. | ||
* | ||
@@ -17,3 +31,3 @@ * @example | ||
*/ | ||
const domReady = function( callback ) { | ||
export default function domReady( callback ) { | ||
if ( | ||
@@ -23,3 +37,3 @@ document.readyState === 'complete' || // DOMContentLoaded + Images/Styles/etc loaded, so we call directly. | ||
) { | ||
return callback(); | ||
return void callback(); | ||
} | ||
@@ -29,4 +43,2 @@ | ||
document.addEventListener( 'DOMContentLoaded', callback ); | ||
}; | ||
export default domReady; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30093
159