Skip to content

Commit

Permalink
fix: prevent multiple runners
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelpeixe committed Oct 8, 2024
1 parent e48e12c commit f3f6992
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/modal-checkout/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ domReady( () => {
iframe.style.visibility = 'hidden';

function iframeReady( cb ) {
let timer;
if ( iframe._readyTimer ) {
clearTimeout( iframe._readyTimer );
}
let fired = false;

function ready() {
if ( ! fired ) {
fired = true;
clearTimeout( timer );
clearTimeout( iframe._readyTimer );
cb.call( this );
}
}
Expand All @@ -73,7 +75,7 @@ domReady( () => {
addEvent( doc, 'readystatechange', readyState );
}
} else {
timer = setTimeout( checkLoaded, 10 );
iframe._readyTimer = setTimeout( checkLoaded, 10 );
}
}
checkLoaded();
Expand Down

0 comments on commit f3f6992

Please sign in to comment.