From: Richard Gibson Date: Sun, 13 Jan 2013 18:10:40 +0000 (-0500) Subject: #13180 unit test X-Git-Tag: 1.9.0~10 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=36457cb6afc12d4a755cf93442a502783a669517;p=jquery.git #13180 unit test --- 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( "" + + "" + "" + "" + + "" + "" - ).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 ) + // 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() {