Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Merge pull request #128 from Polymer/svg-use-target
Browse files Browse the repository at this point in the history
Workaround <use> element event path
  • Loading branch information
dfreedm committed Jan 28, 2014
2 parents b0dd7bd + fdf80d6 commit a8f7de3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
0
];

var HAS_SVG_INSTANCE = (typeof SVGElementInstance !== 'undefined');

/**
* This module is for normalizing events. Mouse and Touch events will be
* collected here, and fire PointerEvents that have the same semantics, no
Expand Down Expand Up @@ -246,6 +248,14 @@
for (var i = 0; i < CLONE_PROPS.length; i++) {
p = CLONE_PROPS[i];
eventCopy[p] = inEvent[p] || CLONE_DEFAULTS[i];
// Work around SVGInstanceElement shadow tree
// Return the <use> element that is represented by the instance for Safari, Chrome, IE.
// This is the behavior implemented by Firefox.
if (HAS_SVG_INSTANCE && (p === 'target' || p === 'relatedTarget')) {
if (eventCopy[p] instanceof SVGElementInstance) {
eventCopy[p] = eventCopy[p].correspondingUseElement;
}
}
}
// keep the semantics of preventDefault
if (inEvent.preventDefault) {
Expand Down

0 comments on commit a8f7de3

Please sign in to comment.