test("Delegated events in SVG (#10791; #13180)", function() {
expect(2);
- var e,
+ var instanceRoot, 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>" +
// 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 ) {
+ instanceRoot = svg.find("#use")[0].instanceRoot;
+ if ( instanceRoot && document.createEvent ) {
e = document.createEvent("MouseEvents");
e.initEvent( "click", true, true );
- svg.find("#use")[0].instanceRoot.dispatchEvent( e );
+ instanceRoot.dispatchEvent( e );
}
jQuery("#qunit-fixture").off("click");