Skip to content

Commit

Permalink
Merge pull request #1490 from alphagov/ldeb-rename-ready
Browse files Browse the repository at this point in the history
Rename and scope document ready handler
  • Loading branch information
lfdebrux authored Jul 28, 2022
2 parents 3b13139 + 63717de commit 8f900ba
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
function ready (fn) {
if (document.readyState !== 'loading') {
// IE9 support
fn()
} else {
// Everything else
document.addEventListener('DOMContentLoaded', fn)
window.GOVUKPrototypeKit = {
documentReady: function (fn) {
if (document.readyState !== 'loading') {
// IE9 support
fn()
} else {
// Everything else
document.addEventListener('DOMContentLoaded', fn)
}
}
}

Expand All @@ -13,6 +15,6 @@ if (window.console && window.console.info) {
window.console.info('GOV.UK Prototype Kit - do not use for production')
}

ready(() => {
window.GOVUKPrototypeKit.documentReady(function () {
window.GOVUKFrontend.initAll()
})

0 comments on commit 8f900ba

Please sign in to comment.