From d39dfaa837c9f6051abf3b9c6cf119369b992833 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Fri, 5 Dec 2014 21:07:57 +0100 Subject: [PATCH] MWCategoryInputWidget: Don't explode on invalid titles canonicalQueryValue can be null at this point, so let's not insert it into an array that contains strings. Bug: T76868 Change-Id: I8096a9c1017e883d28124bf807d2d375ae98452a --- modules/ve-mw/ui/widgets/ve.ui.MWCategoryInputWidget.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWCategoryInputWidget.js b/modules/ve-mw/ui/widgets/ve.ui.MWCategoryInputWidget.js index 04f6959d8c..d9d7a97887 100644 --- a/modules/ve-mw/ui/widgets/ve.ui.MWCategoryInputWidget.js +++ b/modules/ve-mw/ui/widgets/ve.ui.MWCategoryInputWidget.js @@ -112,9 +112,10 @@ ve.ui.MWCategoryInputWidget.prototype.getLookupMenuItemsFromData = function ( da prefixedCanonicalQueryValue = prefixedCanonicalQueryValue && prefixedCanonicalQueryValue.getPrefixedText(); + // Invalid titles end up with canonicalQueryValue being null. if ( canonicalQueryValue ) { canonicalQueryValue = canonicalQueryValue.getMainText(); - } // Invalid titles just end up with canonicalQueryValue being null. + } $.each( data, function ( index, suggestedCategory ) { var suggestedCategoryTitle = mw.Title.newFromText( @@ -151,7 +152,7 @@ ve.ui.MWCategoryInputWidget.prototype.getLookupMenuItemsFromData = function ( da } ); // New category - if ( !exactMatch ) { + if ( !exactMatch && canonicalQueryValue ) { newCategoryItems.push( canonicalQueryValue ); linkCacheUpdate[prefixedCanonicalQueryValue] = { missing: true }; }