
Loading…
Normalized event difference with ShadowDOM and Shady #1921
The expected result is the following on both Shady & Shadow:
-
rootTarget:iron-icon(deepest element that was tapped) -
localTarget:paper-fab(element that had the event listener)
The discrepancy appears to originate in the gesture system. Using click results in the expected results (same between shady & shadow)
It's strange, i've tested it with a click, and localTarget always seems to be my app top-level element, on both shadow and shady.
Wow, forget my last words. I made a mistake : i was logging Polymer.log(e), and then i was clicking on the localTarget property in chrome console to resolve the "getter" ... and it seems it's not correctly resolved (context problem ?)
@kevinpschaaf
I am not sure if this is related to this issue here. But what is the designed behavior when using an annotated event handler on the Local DOM which contains Light DOM elements. I modified your JSBIN and the only get the <h1> as event target: http://jsbin.com/qewahodoxa/edit?html,console,output.
I was expecting to get <x-test> at some point.
Right, the object returned from Polymer.dom(e) has getters that are evaluated lazily, and the event target changes once the event loop completes, so you may see different results if you expand the object on the console later.
You should never expect to see x-test as a target unless the event handler was placed on or above x-test. Since the handler is on elements in the template stamped inside of x-test, localTarget gives you the first element inside the x-test scope (but at or below where the handler was added) as the event bubbles up, while rootTarget should give you the deepest-most element irrespective of scope boundaries (which may or may not be the same thing).
As I said, the bug appears to originate in the gesture system, as it is only the gesture-simulated events that have incorrect targets, not native ones like click.
@kevinpschaaf
I see but in the JSbin I posted, I placed the on-tap and the on-click handler on the x-test element and still get <h1> as localTarget:
<x-test on-click="myHandler"><h1>Click</h1></x-test>
This is just a holdover from the initial design, where gesture events were non-bubbling. Should be pretty easy to change the initiator from nativeEvent.currentTarget to nativeEvent.target.
Ah, so the real problem is that when the event gets to the gesture recognizer, it has already passed through the shadowdom boundary and lost the original target. I'll have to use event.path in the recognizer to fire from the original source.
@kevinpschaaf we may to discuss the performance impact of this for ShadyDOM.
Hello,
i've an element which contains a paper-fab, and a tap event as :
This element is instantiate into a tree of other elements, starting from a top element "my-app" instantiated in the html body.
I've one unique handler for 3 paper-fab. So in the handler, i want to identify the clicked paper-fab.
but i found in the normalized event object that :
with Shady
with ShadowDOM
Anthony.