Skip to main content

Bug Tracker

Side navigation

Ticket #935: jquery_bug935.patch
File jquery_bug935.patch, 1.1 KB (added by jesse, April 17, 2007 01:28PM UTC)

Patch to fix Event data from being global

Index: event.js
===================================================================
--- event.js	(revision 1722)
+++ event.js	(working copy)
@@ -13,14 +13,28 @@
 		if ( jQuery.browser.msie && element.setInterval != undefined )
 			element = window;
 
-		// if data is passed, bind to handler
-		if( data ) 
-			handler.data = data;
-
 		// Make sure that the function being executed has a unique ID
 		if ( !handler.guid )
 			handler.guid = this.guid++;
 
+		// if data is passed, bind to handler
+		if( data != undefined ) {
+			// Create temporary function pointer to original handler
+			var fn = handler;
+
+			// Create unique handler function, wrapped around original handler
+			handler = function() {
+				// Pass arguments and context to original handler
+				return fn.apply(this, arguments);
+			};
+
+			// Store data in unique handler
+			handler.data = data;
+			
+			// Set the guid of unique handler to the same of original handler, so it can be removed
+			handler.guid = fn.guid;
+		}
+
 		// Init the element's event structure
 		if (!element.$events)
 			element.$events = {};

Download in other formats:

Original Format