Added code to short-circuit a .each() loop.

This commit is contained in:
John Resig 2006-10-12 16:37:01 +00:00
parent 96d429b940
commit edb54ef733

View file

@ -1384,10 +1384,10 @@ jQuery.extend({
each: function( obj, fn, args ) { each: function( obj, fn, args ) {
if ( obj.length == undefined ) if ( obj.length == undefined )
for ( var i in obj ) for ( var i in obj )
fn.apply( obj[i], args || [i, obj[i]] ); if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break;
else else
for ( var i = 0; i < obj.length; i++ ) for ( var i = 0; i < obj.length; i++ )
fn.apply( obj[i], args || [i, obj[i]] ); if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break;
return obj; return obj;
}, },