Skip to content

Commit

Permalink
Use global instead of window
Browse files Browse the repository at this point in the history
  • Loading branch information
johnwatkins0 committed Dec 22, 2020
1 parent 8a62bdd commit 747061f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,11 @@ const addBeforeUnloadPrompt = () => {
if ( beforeUnloadPromptAdded ) {
return;
}
// eslint-disable-next-line @wordpress/no-global-event-listener
window.addEventListener( 'beforeunload', onBeforeUnload );
global.addEventListener( 'beforeunload', onBeforeUnload );

// Remove prompt when clicking trash or update.
document.querySelector( '#major-publishing-actions' ).addEventListener( 'click', () => {
// eslint-disable-next-line @wordpress/no-global-event-listener
window.removeEventListener( 'beforeunload', onBeforeUnload );
global.removeEventListener( 'beforeunload', onBeforeUnload );
} );

beforeUnloadPromptAdded = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ class ErrorRows {
} );
};

// eslint-disable-next-line @wordpress/no-global-event-listener
window.addEventListener( 'click', ( event ) => {
global.addEventListener( 'click', ( event ) => {
if ( toggleButtons.includes( event.target ) ) {
onButtonClick( event.target );
}
Expand Down

0 comments on commit 747061f

Please sign in to comment.