} );
} );
// We want to find the row that has the most columns (ignoring colspan)
- $.each( exploded, function ( index, cellArray ) {
+ exploded.forEach( function ( cellArray, index ) {
headerCount = $( uniqueElements( cellArray ) ).filter( 'th' ).length;
if ( headerCount >= maxSeen ) {
maxSeen = headerCount;
*/
function setHeadersOrder( $headers, sortList, headerToColumns ) {
// Loop through all headers to retrieve the indices of the columns the header spans across:
- $.each( headerToColumns, function ( headerIndex, columns ) {
+ headerToColumns.forEach( function ( columns, headerIndex ) {
- $.each( columns, function ( i, columnIndex ) {
+ columns.forEach( function ( columnIndex, i ) {
var header = $headers[ headerIndex ],
$header = $( header );
} );
} else {
// Column shall be sorted: Apply designated count and order.
- $.each( sortList, function ( j, sortColumn ) {
+ sortList.forEach( function ( sortColumn ) {
if ( sortColumn[ 0 ] === i ) {
$header.data( {
order: sortColumn[ 1 ],
}
return ret;
} );
- $.each( rowspanCells, function () {
- $.data( this, 'tablesorter' ).needResort = false;
+ rowspanCells.forEach( function ( cell ) {
+ $.data( cell, 'tablesorter' ).needResort = false;
} );
}
resortCells();
mw.rcfilters.dm.FiltersViewModel.prototype.getFirstConflictedItem = function () {
var conflictedItem;
- $.each( this.getItems(), function ( index, filterItem ) {
+ this.getItems().forEach( function ( filterItem ) {
if ( filterItem.isSelected() && filterItem.isConflicted() ) {
conflictedItem = filterItem;
return false;
label: Util.parseMsg( 'apisandbox-request-selectformat-label' )
}
).$element,
- $.map( formatItems, function ( item ) {
+ formatItems.map( function ( item ) {
return item.getData().$element;
} ),
$result
if ( dates instanceof Date ) {
dates = [ dates ];
} else if ( Array.isArray( dates ) ) {
- dates = $.grep( dates, function ( dt ) { return dt instanceof Date; } );
+ dates = dates.filter( function ( dt ) { return dt instanceof Date; } );
dates.sort();
} else {
dates = [];
$.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 ] ) {
normalizedTitle = normalized[ normalizedTitle ];
// Apply parser regex and set all properties based on the result
matches = parser[ options.strictMode ? 'strict' : 'loose' ].exec( str );
- $.each( properties, function ( i, property ) {
+ properties.forEach( function ( property, i ) {
uri[ property ] = matches[ i + 1 ];
} );
$.each( this.query, function ( key, val ) {
var k = Uri.encode( key ),
vals = Array.isArray( val ) ? val : [ val ];
- $.each( vals, function ( i, v ) {
+ vals.forEach( function ( v ) {
if ( v === null ) {
args.push( k );
} else if ( k === 'title' ) {
}
graph[ moduleName ].requires = dependencies;
- $.each( dependencies, function ( depIndex, depName ) {
+ dependencies.forEach( function ( depName ) {
if ( !hasOwn.call( graph, depName ) ) {
graph[ depName ] = { requiredBy: [] };
}
// Test should use fake XHR, wait for requests, or call abort()
$activeLen = $.active;
if ( $activeLen !== undefined && $activeLen !== 0 ) {
- pending = $.grep( ajaxRequests, function ( ajax ) {
+ pending = ajaxRequests.filter( function ( ajax ) {
return ajax.xhr.state() === 'pending';
} );
if ( pending.length !== $activeLen ) {
mw.log.warn( 'Pending requests does not match jQuery.active count' );
}
// Force requests to stop to give the next test a clean start
- $.each( ajaxRequests, function ( i, ajax ) {
+ ajaxRequests.forEach( function ( ajax, i ) {
mw.log.warn(
'AJAX request #' + i + ' (state: ' + ajax.xhr.state() + ')',
ajax.options
}
];
- $.each( cases, function ( i, item ) {
+ cases.forEach( function ( item ) {
$fixture = $( '<p>' ).text( item.text ).highlightText( item.highlight );
assert.equal(
$fixture.html(),
}
parser = $.tablesorter.getParser( parserId );
- $.each( data, function ( index, testcase ) {
+ data.forEach( function ( testcase ) {
extractedR = parser.is( testcase[ 0 ] );
extractedF = parser.format( testcase[ 0 ] );
$tbody = $table.find( 'tbody' ),
$tr = $( '<tr>' );
- $.each( header, function ( i, str ) {
+ header.forEach( function ( str ) {
var $th = $( '<th>' );
$th.text( str ).appendTo( $tr );
} );
for ( i = 0; i < data.length; i++ ) {
$tr = $( '<tr>' );
// eslint-disable-next-line no-loop-func
- $.each( data[ i ], function ( j, str ) {
+ data[ i ].forEach( function ( str ) {
var $td = $( '<td>' );
$td.text( str ).appendTo( $tr );
} );
} );
this.api.abort();
assert.ok( this.requests.length === 2, 'Check both requests triggered' );
- $.each( this.requests, function ( i, request ) {
+ this.requests.forEach( function ( request, i ) {
assert.ok( request.abort.calledOnce, 'abort request number ' + i );
} );
} );
-( function ( mw, $ ) {
+( function ( mw ) {
QUnit.module( 'mediawiki.RegExp' );
QUnit.test( 'escape', function ( assert ) {
'0123456789'
].join( '' );
- $.each( specials, function ( i, str ) {
+ specials.forEach( function ( str ) {
assert.propEqual( str.match( new RegExp( mw.RegExp.escape( str ) ) ), [ str ], 'Match ' + str );
} );
assert.equal( mw.RegExp.escape( normal ), normal, 'Alphanumerals are left alone' );
} );
-}( mediaWiki, jQuery ) );
+}( mediaWiki ) );
-( function ( mw, $ ) {
+( function ( mw ) {
QUnit.module( 'mediawiki.Uri', QUnit.newMwEnvironment( {
setup: function () {
this.mwUriOrg = mw.Uri;
}
} ) );
- $.each( [ true, false ], function ( i, strictMode ) {
+ [ true, false ].forEach( function ( strictMode ) {
QUnit.test( 'Basic construction and properties (' + ( strictMode ? '' : 'non-' ) + 'strict mode)', function ( assert ) {
var uriString, uri;
uriString = 'http://www.ietf.org/rfc/rfc2396.txt';
href = uri.toString();
assert.equal( href, testProtocol + testServer + ':' + testPort + testPath, 'Root-relative URL gets host, protocol, and port supplied' );
} );
-}( mediaWiki, jQuery ) );
+}( mediaWiki ) );
var queue;
mw.messages.set( 'formatnum-msg', '{{formatnum:$1}}' );
mw.messages.set( 'formatnum-msg-int', '{{formatnum:$1|R}}' );
- queue = $.map( formatnumTests, function ( test ) {
+ queue = formatnumTests.map( function ( test ) {
var done = assert.async();
return function ( next, abort ) {
getMwLanguage( test.lang )
];
Array.prototype.push.apply( IPV6_CASES,
- $.map( [
+ [
'fc:100::',
'fc:100:a::',
'fc:100:a:d::',
'::fc:100:a:d:1:e',
'::fc:100:a:d:1:e:ac',
'fc:100:a:d:1:e:ac:0'
- ], function ( el ) {
- return [ [ true, el, el + ' is a valid IP' ] ];
+ ].map( function ( el ) {
+ return [ true, el, el + ' is a valid IP' ];
} )
);
newExperimental = [ 'html5', 'html5-legacy' ];
// Test cases are kept in sync with SanitizerTest.php
- $.each( [
+ [
// Pure legacy: how MW worked before 2017
[ legacy, text, legacyEncoded ],
// Transition to a new world: legacy links with HTML5 fallback
[ experimentalLegacy, text, html5Experimental ],
// Migration from $wgExperimentalHtmlIds to modern HTML5
[ newExperimental, text, html5Encoded ]
- ], function ( index, testCase ) {
+ ].forEach( function ( testCase ) {
mw.config.set( 'wgFragmentMode', testCase[ 0 ] );
assert.equal( util.escapeIdForAttribute( testCase[ 1 ] ), testCase[ 2 ] );
experimentalLegacy = [ 'html5-legacy', 'legacy' ],
newExperimental = [ 'html5', 'html5-legacy' ];
- $.each( [
+ [
// Pure legacy: how MW worked before 2017
[ legacy, text, legacyEncoded ],
// Transition to a new world: legacy links with HTML5 fallback
[ experimentalLegacy, text, html5Experimental ],
// Migration from wgExperimentalHtmlIds to modern HTML5
[ newExperimental, text, html5Encoded ]
- ], function ( index, testCase ) {
+ ].forEach( function ( testCase ) {
mw.config.set( 'wgFragmentMode', testCase[ 0 ] );
assert.equal( util.escapeIdForLink( testCase[ 1 ] ), testCase[ 2 ] );
} );
QUnit.test( 'isIPv6Address', function ( assert ) {
- $.each( IPV6_CASES, function ( i, ipCase ) {
+ IPV6_CASES.forEach( function ( ipCase ) {
assert.strictEqual( util.isIPv6Address( ipCase[ 1 ] ), ipCase[ 0 ], ipCase[ 2 ] );
} );
} );
QUnit.test( 'isIPv4Address', function ( assert ) {
- $.each( IPV4_CASES, function ( i, ipCase ) {
+ IPV4_CASES.forEach( function ( ipCase ) {
assert.strictEqual( util.isIPv4Address( ipCase[ 1 ] ), ipCase[ 0 ], ipCase[ 2 ] );
} );
} );
QUnit.test( 'isIPAddress', function ( assert ) {
- $.each( IPV4_CASES, function ( i, ipCase ) {
+ IPV4_CASES.forEach( function ( ipCase ) {
assert.strictEqual( util.isIPv4Address( ipCase[ 1 ] ), ipCase[ 0 ], ipCase[ 2 ] );
} );
- $.each( IPV6_CASES, function ( i, ipCase ) {
+ IPV6_CASES.forEach( function ( ipCase ) {
assert.strictEqual( util.isIPv6Address( ipCase[ 1 ] ), ipCase[ 0 ], ipCase[ 2 ] );
} );
} );
/* global isCompatible: true */
-( function ( $ ) {
+( function () {
var testcases = {
tested: [
/* Grade A */
QUnit.module( 'startup', QUnit.newMwEnvironment() );
QUnit.test( 'isCompatible( featureTestable )', function ( assert ) {
- $.each( testcases.tested, function ( i, ua ) {
+ testcases.tested.forEach( function ( ua ) {
assert.strictEqual( isCompatible( ua ), true, ua );
} );
} );
QUnit.test( 'isCompatible( blacklisted )', function ( assert ) {
- $.each( testcases.blacklisted, function ( i, ua ) {
+ testcases.blacklisted.forEach( function ( ua ) {
assert.strictEqual( isCompatible( ua ), false, ua );
} );
} );
-}( jQuery ) );
+}() );