Web APIs

Event.composed

Try the free JavaScript compiler

Indicates whether the event may propagate across a shadow boundary. Distinct from bubbles.

Formal Syntax & Structure

javascript syntaxjavascript
event.composed

Return Value

boolean

Indicates whether the event may propagate across a shadow boundary. Distinct from bubbles.

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);const log=[];document.body.addEventListener("lesson-change",e=>log.push(e.target===host));for(const composed of [false,true])button.dispatchEvent(new CustomEvent("lesson-change",{bubbles:true,composed}));console.log(JSON.stringify(log));})()
JavaScript Reference