Skip to content

Commit 7cd9a36

Browse files
committed
Core: change jQuery.each and jQuery#each signatures
(cherry-picked from 2380028) Fixes gh-2090 Closes gh-2097
1 parent 0877733 commit 7cd9a36

File tree

1 file changed

+10
-31
lines changed

1 file changed

+10
-31
lines changed

src/core.js

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,8 @@ jQuery.fn = jQuery.prototype = {
7373
},
7474

7575
// Execute a callback for every element in the matched set.
76-
// (You can seed the arguments with an array of args, but this is
77-
// only used internally.)
78-
each: function( callback, args ) {
79-
return jQuery.each( this, callback, args );
76+
each: function( callback ) {
77+
return jQuery.each( this, callback );
8078
},
8179

8280
map: function( callback ) {
@@ -295,40 +293,21 @@ jQuery.extend({
295293
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
296294
},
297295

298-
// args is for internal usage only
299-
each: function( obj, callback, args ) {
296+
each: function( obj, callback ) {
300297
var i = 0,
301298
length = obj.length,
302299
isArray = isArraylike( obj );
303300

304-
if ( args ) {
305-
if ( isArray ) {
306-
for ( ; i < length; i++ ) {
307-
if ( callback.apply( obj[ i ], args ) === false ) {
308-
break;
309-
}
310-
}
311-
} else {
312-
for ( i in obj ) {
313-
if ( callback.apply( obj[ i ], args ) === false ) {
314-
break;
315-
}
301+
if ( isArray ) {
302+
for ( ; i < length; i++ ) {
303+
if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
304+
break;
316305
}
317306
}
318-
319-
// A special, fast, case for the most common use of each
320307
} else {
321-
if ( isArray ) {
322-
for ( ; i < length; i++ ) {
323-
if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
324-
break;
325-
}
326-
}
327-
} else {
328-
for ( i in obj ) {
329-
if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
330-
break;
331-
}
308+
for ( i in obj ) {
309+
if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
310+
break;
332311
}
333312
}
334313
}

0 commit comments

Comments
 (0)