]> source.dussan.org Git - jquery.git/commitdiff
Rework #1486 patch to avoid `try/catch` and look for hidden elements by `.offsetWidth...
authorDave Methvin <dave.methvin@gmail.com>
Thu, 8 Sep 2011 01:02:13 +0000 (21:02 -0400)
committertimmywil <timmywillisn@gmail.com>
Mon, 19 Sep 2011 19:42:31 +0000 (15:42 -0400)
src/event.js
test/unit/event.js

index fd61bca83854146d0480d7d98e348a40d58fa4b3..2b05d9a64f8aa1a6713e60edab44739bcbe760c2 100644 (file)
@@ -387,23 +387,21 @@ jQuery.event = {
 
                                // Call a native DOM method on the target with the same name name as the event.
                                // Can't use an .isFunction)() check here because IE6/7 fails that test.
-                               // IE<9 dies on focus to hidden element (#1486), may want to revisit a try/catch.
-                               try {
-                                       if ( ontype && elem[ type ] ) {
-                                               // Don't re-trigger an onFOO event when we call its FOO() method
-                                               old = elem[ ontype ];
-
-                                               if ( old ) {
-                                                       elem[ ontype ] = null;
-                                               }
+                               // IE<9 dies on focus to hidden element (#1486)
+                               if ( ontype && elem[ type ] && elem.offsetWidth !== 0 ) {
+                                       // Don't re-trigger an onFOO event when we call its FOO() method
+                                       old = elem[ ontype ];
 
-                                               jQuery.event.triggered = type;
-                                               elem[ type ]();
+                                       if ( old ) {
+                                               elem[ ontype ] = null;
                                        }
-                               } catch ( ieError ) {}
 
-                               if ( old ) {
-                                       elem[ ontype ] = old;
+                                       jQuery.event.triggered = type;
+                                       elem[ type ]();
+
+                                       if ( old ) {
+                                               elem[ ontype ] = old;
+                                       }
                                }
 
                                jQuery.event.triggered = undefined;
index 5bc20801ac54ce19de5f644a3dc385b059c7d8fa..c00eb202c07eca88b3683a11386e47588b232ec0 100644 (file)
@@ -34,6 +34,31 @@ test("bind(),live(),delegate() with non-null,defined data", function() {
 
 });
 
+/*
+Removed because Chrome 13 snaps/crashes on this 2011-09-07
+
+test("Handler changes and .trigger() order", function() {
+    expect(1);
+
+    var markup = jQuery(
+        '<div><p><b class="a">b</b></p></div>'
+    ).appendTo( "body" );
+
+    var path = "";
+    jQuery( "b" ).parents().bind( "click", function(e){
+        path += this.nodeName.toLowerCase() + " ";
+        // Should not change the event triggering order
+        $(this).parent().remove();
+    });
+
+    markup.find( "b" ).trigger( "click" );
+
+    equals( path, "p div body html ", "Delivered all events" )
+        
+    markup.remove();
+});
+*/
+
 test("bind(), with data", function() {
        expect(4);
        var handler = function(event) {