diff options
author | Richard Gibson <richard.gibson@gmail.com> | 2013-01-13 19:53:19 -0500 |
---|---|---|
committer | Richard Gibson <richard.gibson@gmail.com> | 2013-01-13 20:00:03 -0500 |
commit | b75b9ef8d030b0dbf247e826bfbf9585c7dbf98b (patch) | |
tree | 2dd6ee0411cbef5cfce4e760a0f449c760a48e2e /test | |
parent | 776723436460c928b0eaf88fe36b575f36049a17 (diff) | |
download | jquery-b75b9ef8d030b0dbf247e826bfbf9585c7dbf98b.tar.gz jquery-b75b9ef8d030b0dbf247e826bfbf9585c7dbf98b.zip |
Fix #13180: don't delegate into SVG <use>
(cherry picked from commits 36457cb6afc12d4a755cf93442a502783a669517..f860e0bd2f7dd228a14704d78ed5208cbe870d01)
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/event.js | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/test/unit/event.js b/test/unit/event.js index ff2ea1dd5..182e10b1a 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -1231,17 +1231,21 @@ test(".trigger() doesn't bubble load event (#10717)", function() { jQuery( window ).off( "load" ); }); -test("Delegated events in SVG (#10791)", function() { +test("Delegated events in SVG (#10791; #13180)", function() { expect(2); - var svg = jQuery( + var e, + svg = jQuery( "<svg height='1' version='1.1' width='1' xmlns='http://www.w3.org/2000/svg'>" + + "<defs><rect id='ref' x='10' y='20' width='100' height='60' r='10' rx='10' ry='10'></rect></defs>" + "<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>" + + "<use id='use' xlink:href='#ref'></use>" + "</svg>" - ).appendTo( "body" ); + ); - jQuery( "body" ) + jQuery("#qunit-fixture") + .append( svg ) .on( "click", "#svg-by-id", function() { ok( true, "delegated id selector" ); }) @@ -1249,11 +1253,18 @@ test("Delegated events in SVG (#10791)", function() { ok( true, "delegated class selector" ); }) .find( "#svg-by-id, [class~='svg-by-class']" ) - .trigger( "click" ) - .end() - .off( "click" ); + .trigger("click") + .end(); + + // Fire a native click on an SVGElementInstance (the instance tree of an SVG <use>) + // to confirm that it doesn't break our event delegation handling (#13180) + if ( document.createEvent ) { + e = document.createEvent("MouseEvents"); + e.initEvent( "click", true, true ); + svg.find("#use")[0].instanceRoot.dispatchEvent( e ); + } - svg.remove(); + jQuery("#qunit-fixture").off("click"); }); test("Delegated events in forms (#10844; #11145; #8165; #11382, #11764)", function() { |