CSP.getNewMenuItems = function ( input ) {
var i,
promises = [],
- deferred = new $.Deferred();
+ deferred = $.Deferred();
if ( $.trim( input ) === '' ) {
deferred.resolve( [] );
} );
};
+ /**
+ * @inheritdoc
+ */
+ CSP.getItemFromData = function ( data ) {
+ // This is a bit of a hack... We have to canonicalize the data in the same way that
+ // #createItemWidget and CategoryCapsuleItemWidget will do, otherwise we won't find duplicates.
+ data = mw.Title.newFromText( data, NS_CATEGORY ).getMainText();
+ return OO.ui.mixin.GroupElement.prototype.getItemFromData.call( this, data );
+ };
+
/**
* Validates the values in `this.searchType`.
*
* @return {jQuery.Promise} Resolves with an array of categories
*/
CSP.searchCategories = function ( input, searchType ) {
- var deferred = new $.Deferred();
+ var deferred = $.Deferred();
switch ( searchType ) {
case CategorySelector.SearchType.OpenSearch: