mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Fix #11145: Harden dispatch against a form-aliased "disabled" property
This commit is contained in:
parent
b6a2dfbeb9
commit
77de76b942
@ -399,7 +399,7 @@ jQuery.event = {
|
|||||||
|
|
||||||
// Determine handlers that should run if there are delegated events
|
// Determine handlers that should run if there are delegated events
|
||||||
// Avoid disabled elements in IE (#6911) and non-left-click bubbling in Firefox (#3861)
|
// 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()
|
// Pregenerate a single jQuery object for reuse with .is()
|
||||||
jqcur = jQuery(this);
|
jqcur = jQuery(this);
|
||||||
|
@ -1213,25 +1213,38 @@ test("Delegated events in SVG (#10791)", function() {
|
|||||||
svg.remove();
|
svg.remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Delegated events in forms (#10844)", function() {
|
test("Delegated events in forms (#10844; #11145)", function() {
|
||||||
expect(1);
|
expect(2);
|
||||||
|
|
||||||
// Aliases names like "id" cause havoc
|
// Aliases names like "id" cause havoc
|
||||||
var form = jQuery(
|
var form = jQuery(
|
||||||
'<form id="myform">'+
|
'<form id="myform">'+
|
||||||
'<input type="text" name="id" value="secret agent man" />'+
|
'<input type="text" name="id" value="secret agent man" />'+
|
||||||
'</form>'
|
'</form>'
|
||||||
).appendTo( "body" );
|
)
|
||||||
|
.on( "submit", function( event ) {
|
||||||
jQuery( "body" )
|
event.preventDefault();
|
||||||
.on( "submit", "#myform", function() {
|
|
||||||
ok( true, "delegated id selector with aliased name" );
|
|
||||||
return false;
|
|
||||||
})
|
})
|
||||||
.find( "#myform" )
|
.appendTo("body");
|
||||||
.trigger( "submit" )
|
|
||||||
|
jQuery("body")
|
||||||
|
.on( "submit", "#myform", function() {
|
||||||
|
ok( true, "delegated id selector with aliased id" );
|
||||||
|
})
|
||||||
|
.find("#myform")
|
||||||
|
.trigger("submit")
|
||||||
.end()
|
.end()
|
||||||
.off( "submit" );
|
.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 disabled" );
|
||||||
|
})
|
||||||
|
.find("#myform")
|
||||||
|
.trigger("submit")
|
||||||
|
.end()
|
||||||
|
.off("submit");
|
||||||
|
|
||||||
form.remove();
|
form.remove();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user