Ensure that ve.init.target is correct when re-activating an ArticleTarget

Change-Id: Ic30cd99583019823b51f52ab97ee6f9d7adc53f2
This commit is contained in:
Ed Sanders 2020-03-11 14:45:06 +00:00
parent ee43838e79
commit bcfb250f56
2 changed files with 11 additions and 0 deletions

View file

@ -29,6 +29,13 @@ ve.init.mw.ArticleTarget = function VeInitMwArticleTarget( config ) {
// Parent constructor
ve.init.mw.ArticleTarget.super.call( this, config );
// Register
if ( config.register !== false ) {
// ArticleTargets are never destroyed, but we can't trust ve.init.target to
// not get overridden by other targets that may get created on the page.
ve.init.articleTarget = this;
}
// Properties
this.saveDialog = null;
this.saveDeferred = null;

View file

@ -404,6 +404,10 @@ ve.init.mw.DesktopArticleTarget.prototype.activate = function ( dataPromise ) {
var surface,
target = this;
// We may be re-activating an old target, during which time ve.init.target
// has been overridden.
ve.init.target = ve.init.articleTarget;
if ( !this.active && !this.activating ) {
this.activating = true;
this.activatingDeferred = ve.createDeferred();