Merge "Widgets: Allow titles with name of Object.prototypes"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 22 Jan 2018 20:35:26 +0000 (20:35 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 22 Jan 2018 20:35:26 +0000 (20:35 +0000)
1  2 
resources/src/mediawiki.widgets/mw.widgets.CategoryMultiselectWidget.js

@@@ -5,7 -5,8 +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 ];
                }