diff options
author | Dave Methvin <dave.methvin@gmail.com> | 2011-11-16 10:35:53 -0500 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2011-11-16 10:35:53 -0500 |
commit | 780c59b89d3b7fb9bcc480aa3173693a9d633853 (patch) | |
tree | 777984bc66e8263a700905defa9b73bec59a4811 | |
parent | 80797f5805c335a818bda4237642fc4935bd77f6 (diff) | |
download | jquery-780c59b89d3b7fb9bcc480aa3173693a9d633853.tar.gz jquery-780c59b89d3b7fb9bcc480aa3173693a9d633853.zip |
Fix #10791. SVG clamors for special treatment of its class names.
-rw-r--r-- | src/event.js | 2 | ||||
-rw-r--r-- | test/unit/event.js | 25 |
2 files changed, 26 insertions, 1 deletions
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( + '<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() { expect(5); |