]> source.dussan.org Git - jquery.git/commitdiff
Retooled the native triggering code, simplifying it.
authorJohn Resig <jeresig@gmail.com>
Sat, 5 Dec 2009 04:18:05 +0000 (23:18 -0500)
committerJohn Resig <jeresig@gmail.com>
Sat, 5 Dec 2009 04:18:05 +0000 (23:18 -0500)
src/event.js

index acf363b679047c5277bc0925858cfa2eaa1891ff..3e673d6b994d14017f669b2f125a560c63f808fc 100644 (file)
@@ -257,18 +257,20 @@ jQuery.event = {
                        nativeHandler = elem[ "on" + type ];
                // 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 ) {
-                       event.result = false;
-               }
+
+               var isClick = jQuery.nodeName(elem, "a") && type === "click";
 
                // 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() && !isClick ) {
                        this.triggered = true;
                        try {
                                nativeFn();
                        // prevent IE from throwing an error for some hidden elements
                        } catch (e) {}
+
+               // Handle triggering native .onfoo handlers
+               } else if ( nativeHandler && nativeHandler.apply( elem, data ) === false ) {
+                       event.result = false;
                }
 
                this.triggered = false;