From edb54ef7334831d47591569316beb69e8ad717d6 Mon Sep 17 00:00:00 2001 From: John Resig Date: Thu, 12 Oct 2006 16:37:01 +0000 Subject: [PATCH 1/1] Added code to short-circuit a .each() loop. --- src/jquery/jquery.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 9edd758..8332f64 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -1384,10 +1384,10 @@ jQuery.extend({ each: function( obj, fn, args ) { if ( obj.length == undefined ) 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 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; }, -- 1.7.10.4