mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 06:46:26 +00:00
Switching modes created an infinite loop onBeforeUnload
Switching from visual to source reruns setupUnloadHandlers, which caused an infinite loop where it thought it was its own fallback pre-existing handler. Bug: T153346 Change-Id: I8df55a5395ede02fc34ec47a94f2c780dc08595f
This commit is contained in:
parent
b27fe68833
commit
d6c71632ef
|
@ -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