diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js index 4af11f653c..781738fdf3 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js @@ -215,6 +215,9 @@ ve.init.mw.ViewPageTarget.prototype.deactivate = function ( override ) { this.loading.abort(); } + this.clearState(); + this.docToSave = null; + this.deactivating = false; mw.hook( 've.deactivationComplete' ).fire(); } diff --git a/modules/ve-mw/init/ve.init.mw.Target.js b/modules/ve-mw/init/ve.init.mw.Target.js index 543a756695..2d1618741e 100644 --- a/modules/ve-mw/init/ve.init.mw.Target.js +++ b/modules/ve-mw/init/ve.init.mw.Target.js @@ -60,20 +60,7 @@ ve.init.mw.Target = function VeInitMwTarget( $container, pageName, revisionId ) this.pluginCallbacks = []; this.modulesReady = $.Deferred(); this.preparedCacheKeyPromise = null; - this.loading = false; - this.saving = false; - this.diffing = false; - this.serializing = false; - this.submitting = false; - this.baseTimeStamp = null; - this.startTimeStamp = null; - this.doc = null; - this.editNotices = null; - this.$checkboxes = null; - this.remoteNotices = []; - this.localNoticeMessages = []; - this.sanityCheckFinished = false; - this.sanityCheckVerified = false; + this.clearState(); this.isMobileDevice = ( 'ontouchstart' in window || ( window.DocumentTouch && document instanceof window.DocumentTouch ) @@ -744,6 +731,28 @@ ve.init.mw.Target.prototype.load = function ( additionalModules ) { return true; }; +/** + * Clear the state of this target, preparing it to be reactivated later. + */ +ve.init.mw.Target.prototype.clearState = function () { + this.clearPreparedCacheKey(); + this.loading = false; + this.saving = false; + this.diffing = false; + this.serializing = false; + this.submitting = false; + this.baseTimeStamp = null; + this.startTimeStamp = null; + this.doc = null; + this.originalHtml = null; + this.editNotices = null; + this.$checkboxes = null; + this.remoteNotices = []; + this.localNoticeMessages = []; + this.sanityCheckFinished = false; + this.sanityCheckVerified = false; +}; + /** * Serialize the current document and store the result in the serialization cache on the server. *