Skip to main content

Bug Tracker

Side navigation

Ticket #2111: each.patch


File each.patch, 1.1 KB (added by scottgonzalez, January 04, 2008 02:54AM UTC)

patch to allow breaking out of $.each() for objects

Index: C:/Documents and Settings/Scott/eclipse/workspace/jQuery/core.js
===================================================================
--- C:/Documents and Settings/Scott/eclipse/workspace/jQuery/core.js	(revision 4351)
+++ C:/Documents and Settings/Scott/eclipse/workspace/jQuery/core.js	(working copy)
@@ -710,7 +710,8 @@
 		if ( args ) {
 			if ( object.length == undefined )
 				for ( var name in object )
-					callback.apply( object[ name ], args );
+					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 )
@@ -720,7 +721,8 @@
 		} else {
 			if ( object.length == undefined )
 				for ( var name in object )
-					callback.call( object[ name ], name, object[ name ] );
+					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] ){}

Download in other formats:

Original Format