mirror of
https://github.com/jquery/jquery.git
synced 2026-04-20 03:01:22 -04:00
Added support for breaking in an object loop (Bug #2111).
This commit is contained in:
14
src/core.js
14
src/core.js
@@ -707,20 +707,22 @@ jQuery.extend({
|
||||
// args is for internal usage only
|
||||
each: function( object, callback, args ) {
|
||||
if ( args ) {
|
||||
if ( object.length == undefined )
|
||||
if ( object.length == undefined ) {
|
||||
for ( var name in object )
|
||||
callback.apply( object[ name ], args );
|
||||
else
|
||||
if ( callback.apply( object[ name ], args ) === false )
|
||||
break;
|
||||
} else
|
||||
for ( var i = 0, length = object.length; i < length; i++ )
|
||||
if ( callback.apply( object[ i ], args ) === false )
|
||||
break;
|
||||
|
||||
// A special, fast, case for the most common use of each
|
||||
} else {
|
||||
if ( object.length == undefined )
|
||||
if ( object.length == undefined ) {
|
||||
for ( var name in object )
|
||||
callback.call( object[ name ], name, object[ name ] );
|
||||
else
|
||||
if ( callback.call( object[ name ], name, object[ name ] ) === false )
|
||||
break;
|
||||
} else
|
||||
for ( var i = 0, length = object.length, value = object[0];
|
||||
i < length && callback.call( value, i, value ) !== false; value = object[++i] ){}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user