Merge "Fix sessionfailure i18n message during authentication"
[lhc/web/wiklou.git] / resources / src / mediawiki.widgets / mw.widgets.CategoryCapsuleItemWidget.js
index 4d86cfd..17da7d8 100644 (file)
@@ -6,6 +6,8 @@
  */
 ( function ( $, mw ) {
 
+       var hasOwn = Object.prototype.hasOwnProperty;
+
        /**
         * @class mw.widgets.PageExistenceCache
         * @private
                queue = this.existenceCheckQueue;
                this.existenceCheckQueue = {};
                titles = Object.keys( queue ).filter( function ( title ) {
-                       if ( cache.existenceCache.hasOwnProperty( title ) ) {
+                       if ( hasOwn.call( cache.existenceCache, title ) ) {
                                queue[ title ].resolve( cache.existenceCache[ title ] );
                        }
-                       return !cache.existenceCache.hasOwnProperty( title );
+                       return !hasOwn.call( cache.existenceCache, title );
                } );
                if ( !titles.length ) {
                        return;
@@ -61,9 +63,9 @@
                        $.each( response.query.pages, function ( index, page ) {
                                pages[ page.title ] = !page.missing;
                        } );
-                       $.each( titles, function ( index, title ) {
+                       titles.forEach( function ( title ) {
                                var normalizedTitle = title;
-                               while ( normalized[ normalizedTitle ] ) {
+                               while ( hasOwn.call( normalized, normalizedTitle ) ) {
                                        normalizedTitle = normalized[ normalizedTitle ];
                                }
                                cache.existenceCache[ title ] = pages[ normalizedTitle ];
@@ -81,7 +83,7 @@
         */
        PageExistenceCache.prototype.checkPageExistence = function ( title ) {
                var key = title.getPrefixedText();
-               if ( !this.existenceCheckQueue[ key ] ) {
+               if ( !hasOwn.call( this.existenceCheckQueue, key ) ) {
                        this.existenceCheckQueue[ key ] = $.Deferred();
                }
                this.processExistenceCheckQueueDebounced();
@@ -94,7 +96,8 @@
         * @extends mw.Title
         *
         * @constructor
-        * @inheritdoc
+        * @param {string} title
+        * @param {number} [namespace]
         */
        function ForeignTitle( title, namespace ) {
                // We only need to handle categories here... but we don't know the target language.
        };
 
        /**
-        * @class mw.widgets.CategoryCapsuleItemWidget
-        *
         * Category selector capsule item widget. Extends OO.ui.CapsuleItemWidget with the ability to link
         * to the given page, and to show its existence status (i.e., whether it is a redlink).
         *
+        * @class mw.widgets.CategoryCapsuleItemWidget
         * @uses mw.Api
         * @extends OO.ui.CapsuleItemWidget
         *
                this.$label.replaceWith( this.$link );
                this.setLabelElement( this.$link );
 
-               /*jshint -W024*/
                if ( !this.constructor.static.pageExistenceCaches[ this.apiUrl ] ) {
                        this.constructor.static.pageExistenceCaches[ this.apiUrl ] =
                                new PageExistenceCache( new mw.ForeignApi( this.apiUrl ) );
                        .done( function ( exists ) {
                                widget.setMissing( !exists );
                        } );
-               /*jshint +W024*/
        };
 
        /* Setup */
 
        /* Static Properties */
 
-       /*jshint -W024*/
        /**
         * Map of API URLs to PageExistenceCache objects.
         *
        mw.widgets.CategoryCapsuleItemWidget.static.pageExistenceCaches = {
                '': new PageExistenceCache()
        };
-       /*jshint +W024*/
 
        /* Methods */