From ff587f4f61612a49e2f77904ce1a7744f19c8d39 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Tue, 30 Sep 2014 11:11:09 -0700 Subject: [PATCH] Account for categories being removed twice in MWCategoryWidget Now that we use staging in the meta dialog, the following sequence is possible: * Add Category:Foo in UI (adds to DM and adds a widget) * Remove Category:Foo in UI (removes from DM, removes widget) * Click Cancel to leave meta dialog ** popStaging() *** Undo removal of Foo (adds to DM, does not add a widget) *** Undo addition of Foo (removes from DM, tries to remove nonexistent widget) Add a check so trying to remove an already-removed widget doesn't cause a JS error. Bug: 71471 Change-Id: I34690364ce302b858e2a4429dbb97b57d39aae5f --- modules/ve-mw/ui/widgets/ve.ui.MWCategoryWidget.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWCategoryWidget.js b/modules/ve-mw/ui/widgets/ve.ui.MWCategoryWidget.js index f384e3eb54..a321b2463d 100644 --- a/modules/ve-mw/ui/widgets/ve.ui.MWCategoryWidget.js +++ b/modules/ve-mw/ui/widgets/ve.ui.MWCategoryWidget.js @@ -308,9 +308,11 @@ ve.ui.MWCategoryWidget.prototype.removeItems = function ( names ) { for ( i = 0, len = names.length; i < len; i++ ) { categoryItem = this.categories[names[i]]; - categoryItem.disconnect( this ); - items.push( categoryItem ); - delete this.categories[names[i]]; + if ( categoryItem ) { + categoryItem.disconnect( this ); + items.push( categoryItem ); + delete this.categories[names[i]]; + } } OO.ui.GroupElement.prototype.removeItems.call( this, items );