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
This commit is contained in:
Trevor Parscal 2014-07-15 15:49:51 -07:00
parent b37a947f78
commit f30336bc2e
6 changed files with 6 additions and 8 deletions

View file

@ -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 ) ) {

View file

@ -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 );

View file

@ -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();

View file

@ -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 );

View file

@ -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;

View file

@ -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,