Added code to short-circuit a .each() loop.
authorJohn Resig <jeresig@gmail.com>
Thu, 12 Oct 2006 16:37:01 +0000 (16:37 +0000)
committerJohn Resig <jeresig@gmail.com>
Thu, 12 Oct 2006 16:37:01 +0000 (16:37 +0000)
src/jquery/jquery.js

index 9edd758..8332f64 100644 (file)
@@ -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;
        },