Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Edge/IE11] error with svg use tag #17

Open
Aratramba opened this issue Aug 17, 2016 · 0 comments
Open

[Edge/IE11] error with svg use tag #17

Aratramba opened this issue Aug 17, 2016 · 0 comments

Comments

@Aratramba
Copy link

consider this example:

<svg hidden style="display: none;">
  <defs>
    <circle id="Circle" style="fill: red" r="10"/>
  </defs>
</svg>

<button class="js-button">
  <svg width="100" height="100">
      <use x="10" y="10" xlink:href="#Circle" /> 
  </svg>
</button>

The first svg is used as a spritesheet, and the svg inside the button uses that spritesheet to show the circle.

delegate.bind(document, 'svg', 'click', function (e) {
    console.log(e.delegateTarget);
});

Expected behaviour:

When I click the red circle, I expect a console.log.

Actual behavior:

When I click the red circle, there is no console.log.

Possible fix:

This has probably to do with the shadow tree inside the svg.

when I change var target = e.target || e.srcElement;
to
var target = e.target.correspondingUseElement || e.target || e.srcElement;
it works as expected.

Browsers

seen this at Edge / IE11. Works fine as is in Chrome / Firefox.

not working example: https://jsfiddle.net/35n6f17p/
working example: https://jsfiddle.net/szrpv7bn/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant