Bubbling in Shadow DOM
Last updated
Last updated
Web Components ⟩ Shadow DOM ⟩ Events ⟩
JS.info ⟩ Bubbling, event.composedPath()
If event occurs on an element from shadow DOM, then, as it bubbles out of shadow DOM, its event.target
is reset to <custom-element>
.
For purposes of event bubbling, flattened DOM is used.
if we have a slotted element, and an event occurs somewhere inside it, then it bubbles up to the <slot>
and upwards. 👉 see: tab 1️⃣ (click on slotted element)
The full path to the original event target, with all the shadow elements, can be obtained using event.composedPath()
👉 see: tab 1️⃣