mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-25 03:08:42 +00:00
Merge "Switching modes created an infinite loop onBeforeUnload"
This commit is contained in:
commit
832674fa85
|
@ -33,6 +33,7 @@ ve.init.mw.DesktopArticleTarget = function VeInitMwDesktopArticleTarget( config
|
|||
|
||||
// Properties
|
||||
this.onBeforeUnloadFallback = null;
|
||||
this.onBeforeUnload = this.onBeforeUnload.bind( this );
|
||||
this.onUnloadHandler = this.onUnload.bind( this );
|
||||
this.activating = false;
|
||||
this.deactivating = false;
|
||||
|
@ -1566,11 +1567,13 @@ ve.init.mw.DesktopArticleTarget.prototype.saveEditSection = function ( heading )
|
|||
* @method
|
||||
*/
|
||||
ve.init.mw.DesktopArticleTarget.prototype.setupUnloadHandlers = function () {
|
||||
// Remember any already set beforeunload handler
|
||||
this.onBeforeUnloadFallback = window.onbeforeunload;
|
||||
// Attach our handlers
|
||||
window.onbeforeunload = this.onBeforeUnload.bind( this );
|
||||
window.addEventListener( 'unload', this.onUnloadHandler );
|
||||
if ( window.onbeforeunload !== this.onBeforeUnload ) {
|
||||
// Remember any already set beforeunload handler
|
||||
this.onBeforeUnloadFallback = window.onbeforeunload;
|
||||
// Attach our handlers
|
||||
window.onbeforeunload = this.onBeforeUnload;
|
||||
window.addEventListener( 'unload', this.onUnloadHandler );
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Remove onunload and onbeforunload handlers.
|
||||
|
|
Loading…
Reference in a new issue