From: Fomafix Date: Fri, 12 Jan 2018 15:47:40 +0000 (+0100) Subject: Use native ES5 Array prototype methods instead of jQuery X-Git-Tag: 1.31.0-rc.0~920^2 X-Git-Url: http://git.cyclocoop.org/%22%2C%20generer_url_ecrire%28?a=commitdiff_plain;h=8fb63bad5c22f853050806ccd93b3042bf3a2ae3;p=lhc%2Fweb%2Fwiklou.git Use native ES5 Array prototype methods instead of jQuery Replace * $.each( array, function ( index, value ) { ... } ) by array.forEach( function ( value, index ) { ... } ) * $.grep( array, function ( value ) { ... } ) by array.filter( function ( value ) { ... } ) * $.map( array, function ( value ) { ... } ) by array.map( function ( value ) { ... } ) * $.inArray( value, array ) by array.indexOf( value ) This change is a follow-up to 1edba8029a561919febf8b90f5df689d090665dd. Change-Id: I16134642c52002de0eacb987bed5143f528bf627 --- diff --git a/resources/src/jquery/jquery.suggestions.js b/resources/src/jquery/jquery.suggestions.js index 4f4edc96b5..39c601f3a3 100644 --- a/resources/src/jquery/jquery.suggestions.js +++ b/resources/src/jquery/jquery.suggestions.js @@ -293,7 +293,7 @@ expandFrom = 'left'; // Catch invalid values, default to 'auto' - } else if ( $.inArray( expandFrom, [ 'left', 'right', 'start', 'end', 'auto' ] ) === -1 ) { + } else if ( [ 'left', 'right', 'start', 'end', 'auto' ].indexOf( expandFrom ) === -1 ) { expandFrom = 'auto'; } @@ -757,7 +757,7 @@ ]; if ( context.data.keypressedCount === 0 && e.which === context.data.keypressed && - $.inArray( e.which, allowed ) !== -1 + allowed.indexOf( e.which ) !== -1 ) { $.suggestions.keypress( e, context, context.data.keypressed ); } diff --git a/resources/src/jquery/jquery.tablesorter.js b/resources/src/jquery/jquery.tablesorter.js index 21209f67d2..6d67ade978 100644 --- a/resources/src/jquery/jquery.tablesorter.js +++ b/resources/src/jquery/jquery.tablesorter.js @@ -289,8 +289,8 @@ function uniqueElements( array ) { var uniques = []; - $.each( array, function ( i, elem ) { - if ( elem !== undefined && $.inArray( elem, uniques ) === -1 ) { + array.forEach( function ( elem ) { + if ( elem !== undefined && uniques.indexOf( elem ) === -1 ) { uniques.push( elem ); } } ); @@ -925,9 +925,8 @@ cell = this; // Get current column index columns = config.headerToColumns[ $cell.data( 'headerIndex' ) ]; - newSortList = $.map( columns, function ( c ) { - // jQuery "helpfully" flattens the arrays... - return [ [ c, $cell.data( 'order' ) ] ]; + newSortList = columns.map( function ( c ) { + return [ c, $cell.data( 'order' ) ]; } ); // Index of first column belonging to this header i = columns[ 0 ]; diff --git a/resources/src/mediawiki.action/mediawiki.action.edit.stash.js b/resources/src/mediawiki.action/mediawiki.action.edit.stash.js index 31c22af244..5ae91e8564 100644 --- a/resources/src/mediawiki.action/mediawiki.action.edit.stash.js +++ b/resources/src/mediawiki.action/mediawiki.action.edit.stash.js @@ -156,7 +156,7 @@ mw.util.getParamValue( 'undo' ) !== null || // Pressing "show changes" and "preview" also signify that the user will // probably save the page soon - $.inArray( $form.find( '#mw-edit-mode' ).val(), [ 'preview', 'diff' ] ) > -1 + [ 'preview', 'diff' ].indexOf( $form.find( '#mw-edit-mode' ).val() ) > -1 ) { checkStash(); } diff --git a/resources/src/mediawiki.special/mediawiki.special.apisandbox.js b/resources/src/mediawiki.special/mediawiki.special.apisandbox.js index a6450e9136..35d82b2bbd 100644 --- a/resources/src/mediawiki.special/mediawiki.special.apisandbox.js +++ b/resources/src/mediawiki.special/mediawiki.special.apisandbox.js @@ -1420,7 +1420,7 @@ for ( j = 0; j < tmp.length; j++ ) { availableFormats[ tmp[ j ] ] = true; } - pi.parameters[ i ].type = $.grep( tmp, filterFmModules ); + pi.parameters[ i ].type = tmp.filter( filterFmModules ); pi.parameters[ i ][ 'default' ] = 'json'; pi.parameters[ i ].required = true; } @@ -1429,7 +1429,7 @@ // Hide the 'wrappedhtml' parameter on format modules if ( pi.group === 'format' ) { - pi.parameters = $.grep( pi.parameters, function ( p ) { + pi.parameters = pi.parameters.filter( function ( p ) { return p.name !== 'wrappedhtml'; } ); } @@ -1451,7 +1451,7 @@ popup: { width: 'auto', padded: true, - $content: $( '