Commit 780c59b8 authored by Dave Methvin's avatar Dave Methvin

Fix #10791. SVG clamors for special treatment of its class names.

parent 80797f58
...@@ -21,7 +21,7 @@ var rformElems = /^(?:textarea|input|select)$/i, ...@@ -21,7 +21,7 @@ var rformElems = /^(?:textarea|input|select)$/i,
return ( return (
(!m[1] || elem.nodeName.toLowerCase() === m[1]) && (!m[1] || elem.nodeName.toLowerCase() === m[1]) &&
(!m[2] || elem.id === m[2]) && (!m[2] || elem.id === m[2]) &&
(!m[3] || m[3].test( elem.className )) (!m[3] || m[3].test( ((elem.attributes || {})[ "class" ] || {}).value ))
); );
}, },
hoverHack = function( events ) { hoverHack = function( events ) {
......
...@@ -1184,6 +1184,31 @@ test(".trigger() doesn't bubble load event (#10717)", function() { ...@@ -1184,6 +1184,31 @@ test(".trigger() doesn't bubble load event (#10717)", function() {
jQuery( window ).off( "load" ); jQuery( window ).off( "load" );
}); });
test("Delegated events in SVG (#10791)", function() {
expect(2);
var svg = jQuery(
'<svg height="1" version="1.1" width="1" xmlns="http://www.w3.org/2000/svg">'+
'<rect class="svg-by-class" x="10" y="20" width="100" height="60" r="10" rx="10" ry="10"></rect>'+
'<rect id="svg-by-id" x="10" y="20" width="100" height="60" r="10" rx="10" ry="10"></rect>'+
'</svg>'
).appendTo( "body" );
jQuery( "body" )
.on( "click", "#svg-by-id", function() {
ok( true, "delegated id selector" );
})
.on( "click", ".svg-by-class", function() {
ok( true, "delegated class selector" );
})
.find( "#svg-by-id, .svg-by-class" )
.trigger( "click" )
.end()
.off( "click" );
svg.remove();
});
test("jQuery.Event( type, props )", function() { test("jQuery.Event( type, props )", function() {
expect(5); expect(5);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment