mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Fix #10844. Harden quickIs() against form-aliasing of the id property.
This commit is contained in:
parent
1eb1ad6160
commit
8cb065addc
@ -18,10 +18,11 @@ var rformElems = /^(?:textarea|input|select)$/i,
|
||||
return quick;
|
||||
},
|
||||
quickIs = function( elem, m ) {
|
||||
var attrs = elem.attributes || {};
|
||||
return (
|
||||
(!m[1] || elem.nodeName.toLowerCase() === m[1]) &&
|
||||
(!m[2] || elem.id === m[2]) &&
|
||||
(!m[3] || m[3].test( ((elem.attributes || {})[ "class" ] || {}).value ))
|
||||
(!m[2] || (attrs.id || {}).value === m[2]) &&
|
||||
(!m[3] || m[3].test( (attrs[ "class" ] || {}).value ))
|
||||
);
|
||||
},
|
||||
hoverHack = function( events ) {
|
||||
|
@ -1209,6 +1209,29 @@ test("Delegated events in SVG (#10791)", function() {
|
||||
svg.remove();
|
||||
});
|
||||
|
||||
test("Delegated events in forms (#10844)", function() {
|
||||
expect(1);
|
||||
|
||||
// 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", "#myform", function() {
|
||||
ok( true, "delegated id selector with aliased name" );
|
||||
return false;
|
||||
})
|
||||
.find( "#myform" )
|
||||
.trigger( "submit" )
|
||||
.end()
|
||||
.off( "submit" );
|
||||
|
||||
form.remove();
|
||||
});
|
||||
|
||||
test("jQuery.Event( type, props )", function() {
|
||||
|
||||
expect(5);
|
||||
|
Loading…
Reference in New Issue
Block a user