diff options
author | Richard Gibson <richard.gibson@gmail.com> | 2012-01-11 21:56:18 -0500 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2012-01-11 21:56:18 -0500 |
commit | 77de76b942bf6bde5cf17ddad15b03049c92e6be (patch) | |
tree | c02f2de1d9ce98e4ac5c3b2a431f4c3276c758b8 | |
parent | b6a2dfbeb9ff77aa7776fd3439ad431b1100c51b (diff) | |
download | jquery-77de76b942bf6bde5cf17ddad15b03049c92e6be.tar.gz jquery-77de76b942bf6bde5cf17ddad15b03049c92e6be.zip |
Fix #11145: Harden dispatch against a form-aliased "disabled" property
-rw-r--r-- | src/event.js | 2 | ||||
-rw-r--r-- | test/unit/event.js | 33 |
2 files changed, 24 insertions, 11 deletions
diff --git a/src/event.js b/src/event.js index 98822bdaf..150aba2fd 100644 --- a/src/event.js +++ b/src/event.js @@ -399,7 +399,7 @@ jQuery.event = { // Determine handlers that should run if there are delegated events // Avoid disabled elements in IE (#6911) and non-left-click bubbling in Firefox (#3861) - if ( delegateCount && !event.target.disabled && !(event.button && event.type === "click") ) { + if ( delegateCount && event.target.disabled !== true && !(event.button && event.type === "click") ) { // Pregenerate a single jQuery object for reuse with .is() jqcur = jQuery(this); diff --git a/test/unit/event.js b/test/unit/event.js index 81571506b..762617733 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -1213,25 +1213,38 @@ test("Delegated events in SVG (#10791)", function() { svg.remove(); }); -test("Delegated events in forms (#10844)", function() { - expect(1); +test("Delegated events in forms (#10844; #11145)", function() { + expect(2); // Aliases names like "id" cause havoc var form = jQuery( '<form id="myform">'+ '<input type="text" name="id" value="secret agent man" />'+ '</form>' - ).appendTo( "body" ); - - jQuery( "body" ) + ) + .on( "submit", function( event ) { + event.preventDefault(); + }) + .appendTo("body"); + + jQuery("body") + .on( "submit", "#myform", function() { + ok( true, "delegated id selector with aliased id" ); + }) + .find("#myform") + .trigger("submit") + .end() + .off("submit"); + + form.append('<input type="text" name="disabled" value="differently abled" />'); + jQuery("body") .on( "submit", "#myform", function() { - ok( true, "delegated id selector with aliased name" ); - return false; + ok( true, "delegated id selector with aliased disabled" ); }) - .find( "#myform" ) - .trigger( "submit" ) + .find("#myform") + .trigger("submit") .end() - .off( "submit" ); + .off("submit"); form.remove(); }); |