From: Dave Methvin Date: Wed, 16 Nov 2011 15:35:53 +0000 (-0500) Subject: Fix #10791. SVG clamors for special treatment of its class names. X-Git-Tag: 1.7.1rc1~6 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=780c59b89d3b7fb9bcc480aa3173693a9d633853;p=jquery.git Fix #10791. SVG clamors for special treatment of its class names. --- diff --git a/src/event.js b/src/event.js index c6a711882..57fe00cbe 100644 --- a/src/event.js +++ b/src/event.js @@ -21,7 +21,7 @@ var rformElems = /^(?:textarea|input|select)$/i, return ( (!m[1] || elem.nodeName.toLowerCase() === m[1]) && (!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 ) { diff --git a/test/unit/event.js b/test/unit/event.js index c207d0289..eb5f98fb8 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -1184,6 +1184,31 @@ test(".trigger() doesn't bubble load event (#10717)", function() { jQuery( window ).off( "load" ); }); +test("Delegated events in SVG (#10791)", function() { + expect(2); + + var svg = jQuery( + ''+ + ''+ + ''+ + '' + ).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() { expect(5);