mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Core: change jQuery.each and jQuery#each signatures
Fixes gh-2090 Closes gh-2097
This commit is contained in:
parent
a4715f4216
commit
2380028ec4
41
src/core.js
41
src/core.js
@ -74,10 +74,8 @@ jQuery.fn = jQuery.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Execute a callback for every element in the matched set.
|
// Execute a callback for every element in the matched set.
|
||||||
// (You can seed the arguments with an array of args, but this is
|
each: function( callback ) {
|
||||||
// only used internally.)
|
return jQuery.each( this, callback );
|
||||||
each: function( callback, args ) {
|
|
||||||
return jQuery.each( this, callback, args );
|
|
||||||
},
|
},
|
||||||
|
|
||||||
map: function( callback ) {
|
map: function( callback ) {
|
||||||
@ -269,40 +267,21 @@ jQuery.extend({
|
|||||||
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
|
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
|
||||||
},
|
},
|
||||||
|
|
||||||
// args is for internal usage only
|
each: function( obj, callback ) {
|
||||||
each: function( obj, callback, args ) {
|
|
||||||
var i = 0,
|
var i = 0,
|
||||||
length = obj.length,
|
length = obj.length,
|
||||||
isArray = isArraylike( obj );
|
isArray = isArraylike( obj );
|
||||||
|
|
||||||
if ( args ) {
|
if ( isArray ) {
|
||||||
if ( isArray ) {
|
for ( ; i < length; i++ ) {
|
||||||
for ( ; i < length; i++ ) {
|
if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
|
||||||
if ( callback.apply( obj[ i ], args ) === false ) {
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for ( i in obj ) {
|
|
||||||
if ( callback.apply( obj[ i ], args ) === false ) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A special, fast, case for the most common use of each
|
|
||||||
} else {
|
} else {
|
||||||
if ( isArray ) {
|
for ( i in obj ) {
|
||||||
for ( ; i < length; i++ ) {
|
if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
|
||||||
if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for ( i in obj ) {
|
|
||||||
if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user