From f30336bc2e1509bf81b2fa246b4b6cbe92653ad9 Mon Sep 17 00:00:00 2001 From: Trevor Parscal Date: Tue, 15 Jul 2014 15:49:51 -0700 Subject: [PATCH] Always initialize data before use LinkNodeInspector was broken when you clicked away/pressed escape, because data was not set. Normalizing on data being initialized at the top of get*Process methods if used. Change-Id: I89728ac558545a6f2c325014b6f457ec6bef17b8 --- modules/ve-mw/ui/dialogs/ve.ui.MWMetaDialog.js | 4 +--- modules/ve-mw/ui/dialogs/ve.ui.MWReferenceDialog.js | 1 + modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js | 4 +--- .../ve-mw/ui/dialogs/ve.ui.MWWikitextSwitchConfirmDialog.js | 3 +-- modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js | 1 + modules/ve-mw/ui/inspectors/ve.ui.MWLinkNodeInspector.js | 1 + 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWMetaDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWMetaDialog.js index 037722f693..d4463628e3 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWMetaDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWMetaDialog.js @@ -135,11 +135,9 @@ ve.ui.MWMetaDialog.prototype.getActionProcess = function ( action ) { * @inheritdoc */ ve.ui.MWMetaDialog.prototype.getSetupProcess = function ( data ) { + data = data || {}; return ve.ui.MWMetaDialog.super.prototype.getSetupProcess.call( this, data ) .next( function () { - // Data initialization - data = data || {}; - var surfaceModel = this.getFragment().getSurface(); if ( data.page && this.bookletLayout.getPage( data.page ) ) { diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWReferenceDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWReferenceDialog.js index 19dffc277b..c93bedf0ed 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWReferenceDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWReferenceDialog.js @@ -363,6 +363,7 @@ ve.ui.MWReferenceDialog.prototype.getActionProcess = function ( action ) { * @param {boolean} [data.useExistingReference] Open the dialog in "use existing reference" mode */ ve.ui.MWReferenceDialog.prototype.getSetupProcess = function ( data ) { + data = data || {}; return ve.ui.MWReferenceDialog.super.prototype.getSetupProcess.call( this, data ) .next( function () { this.panels.setItem( this.editPanel ); diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js index 227da7b91b..29f53a6cfa 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js @@ -354,13 +354,11 @@ ve.ui.MWTemplateDialog.prototype.getActionProcess = function ( action ) { * @inheritdoc */ ve.ui.MWTemplateDialog.prototype.getSetupProcess = function ( data ) { + data = data || {}; return ve.ui.MWTemplateDialog.super.prototype.getSetupProcess.call( this, data ) .next( function () { var template, promise; - // Data initialization - data = data || {}; - // Properties this.loaded = false; this.transclusionModel = new ve.dm.MWTransclusionModel(); diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWWikitextSwitchConfirmDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWWikitextSwitchConfirmDialog.js index 350e263ed9..ab72819bd8 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWWikitextSwitchConfirmDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWWikitextSwitchConfirmDialog.js @@ -78,10 +78,9 @@ ve.ui.MWWikitextSwitchConfirmDialog.prototype.getActionProcess = function ( acti * @inheritdoc */ ve.ui.MWWikitextSwitchConfirmDialog.prototype.getTeardownProcess = function ( data ) { + data = data || {}; return ve.ui.MWWikitextSwitchConfirmDialog.super.prototype.getTeardownProcess.call( this, data ) .first( function () { - data = data || {}; - // EVIL HACK - we shouldn't be reaching into the manager for these promises if ( data.action === 'switch' || data.action === 'discard' ) { this.manager.closing.resolve( data ); diff --git a/modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js b/modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js index da45713fef..ecf65cfce5 100644 --- a/modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js +++ b/modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js @@ -89,6 +89,7 @@ ve.ui.MWExtensionInspector.prototype.getInputPlaceholder = function () { * @inheritdoc */ ve.ui.MWExtensionInspector.prototype.getSetupProcess = function ( data ) { + data = data || {}; return ve.ui.MWExtensionInspector.super.prototype.getSetupProcess.call( this, data ) .next( function () { var value, dir; diff --git a/modules/ve-mw/ui/inspectors/ve.ui.MWLinkNodeInspector.js b/modules/ve-mw/ui/inspectors/ve.ui.MWLinkNodeInspector.js index e474614ae8..349edcad45 100644 --- a/modules/ve-mw/ui/inspectors/ve.ui.MWLinkNodeInspector.js +++ b/modules/ve-mw/ui/inspectors/ve.ui.MWLinkNodeInspector.js @@ -98,6 +98,7 @@ ve.ui.MWLinkNodeInspector.prototype.getReadyProcess = function ( data ) { * @inheritdoc */ ve.ui.MWLinkNodeInspector.prototype.getTeardownProcess = function ( data ) { + data = data || {}; return ve.ui.MWLinkNodeInspector.super.prototype.getTeardownProcess.call( this, data ) .first( function () { var content, annotation, annotations,