Skip to main content

Bug Tracker

Side navigation

Ticket #5124: event.diff
File event.diff, 1.6 KB (added by mike.helgeson, August 25, 2009 05:28PM UTC)
--- C:\Documents and Settings\mhelgeson\Desktop\CODE\jquery\src\event.js	Tue Aug 25 13:18:56 2009
+++ C:\Temp\event.js	Tue Aug 25 13:16:43 2009
@@ -247,24 +247,32 @@
 			handle.apply( elem, data );
 		}
 
-		var nativeFn, nativeHandler;
+		var aclick = ( jQuery.nodeName(elem, 'a') && type === "click" ),
+		nativeFn, nativeHandler = function(){
+			try {
+				if ( elem[ "on" + type ] )
+					return elem[ "on" + type ].apply( elem, data );
+				}
+			// catch some IE issues	
+			catch( ex ){ }
+			};
 		try {
-			nativeFn = elem[ type ];
-			nativeHandler = elem[ "on" + type ];
+			nativeFn = !!elem[ type ] ? function(){ 
+				try {
+					elem[ type ]();
+				} catch(e) {}
+			} : null;
 		// prevent IE from throwing an error for some elements with some event types, see #3533
 		} catch (e) {}
 		// Handle triggering native .onfoo handlers (and on links since we don't call .click() for links)
-		if ( (!nativeFn || (jQuery.nodeName(elem, 'a') && type === "click")) && nativeHandler && nativeHandler.apply( elem, data ) === false ) {
+		if ( (!nativeFn || aclick) && nativeHandler() === false ) {
 			event.result = false;
 		}
 
 		// Trigger the native events (except for clicks on links)
-		if ( !bubbling && nativeFn && !event.isDefaultPrevented() && !(jQuery.nodeName(elem, 'a') && type === "click") ) {
+		if ( !bubbling && nativeFn && !event.isDefaultPrevented() && !aclick ) {
 			this.triggered = true;
-			try {
-				nativeFn();
-			// prevent IE from throwing an error for some hidden elements
-			} catch (e) {}
+			nativeFn();
 		}
 
 		this.triggered = false;

Download in other formats:

Original Format