Web APIs

Event.prototype.composedPath()

Try the free JavaScript compiler

Returns the observable event invocation path; closed shadow internals are not exposed to outside listeners.

Formal Syntax & Structure

javascript syntaxjavascript
event.composedPath()

Return Value

EventTarget[]

Returns the observable event invocation path; closed shadow internals are not exposed to outside listeners.

Working Example

Example Snippetjavascript
(async () => {const host=document.createElement("div");const root=host.attachShadow({mode:"open"});const button=document.createElement("button");root.append(button);document.body.append(host);host.addEventListener("lesson-signal",e=>console.log(e.target===host,e.composedPath()[0]===button));button.dispatchEvent(new CustomEvent("lesson-signal",{bubbles:true,composed:true}));})()
JavaScript Reference