Merge "resourceloader: Simplify StringSet fallback"
[lhc/web/wiklou.git] / resources / src / mediawiki.special.apisandbox / apisandbox.js
index f936658..48b3269 100644 (file)
@@ -1,4 +1,5 @@
-( function ( $, mw, OO ) {
+/* eslint-disable no-restricted-properties */
+( function () {
        'use strict';
        var ApiSandbox, Util, WidgetMethods, Validators,
                $content, panel, booklet, oldhash, windowManager,
                        var apiPromise,
                                deferred = $.Deferred();
 
-                       if ( moduleInfoCache.hasOwnProperty( module ) ) {
+                       if ( Object.prototype.hasOwnProperty.call( moduleInfoCache, module ) ) {
                                return deferred
                                        .resolve( moduleInfoCache[ module ] )
                                        .promise( { abort: function () {} } );
 
                                subpages = page.getSubpages();
                                for ( i = 0; i < subpages.length; i++ ) {
-                                       if ( pages.hasOwnProperty( subpages[ i ].key ) ) {
+                                       if ( Object.prototype.hasOwnProperty.call( pages, subpages[ i ].key ) ) {
                                                checkPages.push( pages[ subpages[ i ].key ] );
                                        }
                                }
                                        if ( page.getSubpages ) {
                                                subpages = page.getSubpages();
                                                for ( j = 0; j < subpages.length; j++ ) {
-                                                       if ( !pages.hasOwnProperty( subpages[ j ].key ) ) {
+                                                       if ( !Object.prototype.hasOwnProperty.call( pages, subpages[ j ].key ) ) {
                                                                subpages[ j ].indentLevel = page.indentLevel + 1;
                                                                pages[ subpages[ j ].key ] = new ApiSandbox.PageLayout( subpages[ j ] );
                                                        }
                                page.getQueryParams( params, displayParams );
                                subpages = page.getSubpages();
                                for ( i = 0; i < subpages.length; i++ ) {
-                                       if ( pages.hasOwnProperty( subpages[ i ].key ) ) {
+                                       if ( Object.prototype.hasOwnProperty.call( pages, subpages[ i ].key ) ) {
                                                checkPages.push( pages[ subpages[ i ].key ] );
                                        }
                                }
 
                                // Force a 'fm' format with wrappedhtml=1, if available
                                if ( params.format !== undefined ) {
-                                       if ( availableFormats.hasOwnProperty( params.format + 'fm' ) ) {
+                                       if ( Object.prototype.hasOwnProperty.call( availableFormats, params.format + 'fm' ) ) {
                                                params.format = params.format + 'fm';
                                        }
                                        if ( params.format.substr( -2 ) === 'fm' ) {
 
                                subpages = page.getSubpages();
                                for ( i = 0; i < subpages.length; i++ ) {
-                                       if ( pages.hasOwnProperty( subpages[ i ].key ) ) {
+                                       if ( Object.prototype.hasOwnProperty.call( pages, subpages[ i ].key ) ) {
                                                checkPages.push( pages[ subpages[ i ].key ] );
                                        }
                                }
                                page.apiCheckValid();
                                subpages = page.getSubpages();
                                for ( i = 0; i < subpages.length; i++ ) {
-                                       if ( pages.hasOwnProperty( subpages[ i ].key ) ) {
+                                       if ( Object.prototype.hasOwnProperty.call( pages, subpages[ i ].key ) ) {
                                                checkPages.push( pages[ subpages[ i ].key ] );
                                        }
                                }
                }
 
                toRemove = {};
+               // eslint-disable-next-line no-restricted-properties
                $.each( this.templatedItemsCache, function ( k, el ) {
                        if ( el.widget.isElementAttached() ) {
                                toRemove[ k ] = el;
                                                }
                                        }
                                        if ( params ) {
-                                               tmp.widget.setApiValue( params.hasOwnProperty( name ) ? params[ name ] : undefined );
+                                               tmp.widget.setApiValue( Object.prototype.hasOwnProperty.call( params, name ) ? params[ name ] : undefined );
                                        }
                                } else {
                                        newVars = {};
                                        buttons = [],
                                        filterFmModules = function ( v ) {
                                                return v.substr( -2 ) !== 'fm' ||
-                                                       !availableFormats.hasOwnProperty( v.substr( 0, v.length - 2 ) );
+                                                       !Object.prototype.hasOwnProperty.call( availableFormats, v.substr( 0, v.length - 2 ) );
                                        };
 
                                // This is something of a hack. We always want the 'format' and
                                return widget.apiCheckValid();
                        } );
                        $.when.apply( $, promises ).then( function () {
-                               that.apiIsValid = $.inArray( false, arguments ) === -1;
+                               that.apiIsValid = Array.prototype.indexOf.call( arguments, false ) === -1;
                                if ( that.getOutlineItem() ) {
                                        that.getOutlineItem().setIcon( that.apiIsValid || suppressErrors ? null : 'alert' );
                                        that.getOutlineItem().setIconTitle(
                        this.loadFromQueryParams = params;
                } else {
                        $.each( this.widgets, function ( name, widget ) {
-                               var v = params.hasOwnProperty( name ) ? params[ name ] : undefined;
+                               var v = Object.prototype.hasOwnProperty.call( params, name ) ? params[ name ] : undefined;
                                widget.setApiValue( v );
                        } );
                        this.updateTemplatedParameters( params );
 
        module.exports = ApiSandbox;
 
-}( jQuery, mediaWiki, OO ) );
+}() );