mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Core: Simplify and speed up .each
Closes gh-1510
(cherry picked from commit eeda11cdd6
)
This commit is contained in:
parent
aec41a5c41
commit
4cc4e54298
19
src/core.js
19
src/core.js
@ -301,25 +301,20 @@ jQuery.extend({
|
|||||||
|
|
||||||
// args is for internal usage only
|
// args is for internal usage only
|
||||||
each: function( obj, callback, args ) {
|
each: function( obj, callback, args ) {
|
||||||
var value,
|
var i = 0,
|
||||||
i = 0,
|
|
||||||
length = obj.length,
|
length = obj.length,
|
||||||
isArray = isArraylike( obj );
|
isArray = isArraylike( obj );
|
||||||
|
|
||||||
if ( args ) {
|
if ( args ) {
|
||||||
if ( isArray ) {
|
if ( isArray ) {
|
||||||
for ( ; i < length; i++ ) {
|
for ( ; i < length; i++ ) {
|
||||||
value = callback.apply( obj[ i ], args );
|
if ( callback.apply( obj[ i ], args ) === false ) {
|
||||||
|
|
||||||
if ( value === false ) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for ( i in obj ) {
|
for ( i in obj ) {
|
||||||
value = callback.apply( obj[ i ], args );
|
if ( callback.apply( obj[ i ], args ) === false ) {
|
||||||
|
|
||||||
if ( value === false ) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -329,17 +324,13 @@ jQuery.extend({
|
|||||||
} else {
|
} else {
|
||||||
if ( isArray ) {
|
if ( isArray ) {
|
||||||
for ( ; i < length; i++ ) {
|
for ( ; i < length; i++ ) {
|
||||||
value = callback.call( obj[ i ], i, obj[ i ] );
|
if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
|
||||||
|
|
||||||
if ( value === false ) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for ( i in obj ) {
|
for ( i in obj ) {
|
||||||
value = callback.call( obj[ i ], i, obj[ i ] );
|
if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
|
||||||
|
|
||||||
if ( value === false ) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user