Skip to content

Commit

Permalink
Avoid double-declaring domReady JS function which exists
Browse files Browse the repository at this point in the history
at UCP notification options page.
  • Loading branch information
rxu committed May 26, 2024
1 parent fbf6ec2 commit d4523cb
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions styles/all/template/update_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ function webpushWorkerUpdate() {
});
}
}

function domReady(callBack) {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', callBack);
} else {
callBack();
// Do not redeclare function if exist
if (typeof domReady === 'undefined') {
window.domReady = function(callBack) {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', callBack);
} else {
callBack();
}
}
}

Expand Down

0 comments on commit d4523cb

Please sign in to comment.