Merge "Only try to show character difference if it isn't empty"
[lhc/web/wiklou.git] / resources / src / mediawiki.widgets / mw.widgets.CategoryMultiselectWidget.js
index d14a47a..b3bcc0d 100644 (file)
@@ -5,7 +5,8 @@
  * @license The MIT License (MIT); see LICENSE.txt
  */
 ( function ( $, mw ) {
-       var NS_CATEGORY = mw.config.get( 'wgNamespaceIds' ).category;
+       var hasOwn = Object.prototype.hasOwnProperty,
+               NS_CATEGORY = mw.config.get( 'wgNamespaceIds' ).category;
 
        /**
         * Category selector widget. Displays an OO.ui.CapsuleMultiselectWidget
                        promises = [],
                        deferred = $.Deferred();
 
-               if ( $.trim( input ) === '' ) {
+               if ( input.trim() === '' ) {
                        deferred.resolve( [] );
                        return deferred.promise();
                }
                        cacheKey = input + searchType.toString();
 
                // Check cache
-               if ( this.searchCache[ cacheKey ] !== undefined ) {
+               if ( hasOwn.call( this.searchCache, cacheKey ) ) {
                        return this.searchCache[ cacheKey ];
                }
 
                /** Search for existing categories with the exact title */
                Exists: 2,
 
-               /** Search only subcategories  */
+               /** Search only subcategories */
                SubCategories: 3,
 
                /** Search only parent categories */