I am rewriting my Polymer 1.0
application to Polymer 2.0
(and TS) and I encountered a problem. How to transfer an event from one element to another? I used an iron-signal
earlier, now I'm trying to use the CustomEvent
, but because of the ShadowDOM
event does not reach the element.
The hierarchy of elements is approximately the following:
1 {2 {3 {4}}}}
.
I need to throw an event from element 1
to element 4
, and in another case, vice versa.
How can I do that? Only through window.AddEventListener
?
By default, custom events stop at shadow DOM boundaries. To make a custom event pass through shadow DOM boundaries, set the composed flag to true when you create the event:
var event = new CustomEvent('my-event', {bubbles: true, composed: true});