Web APIs
Event.composed
Indicates whether the event may propagate across a shadow boundary. Distinct from bubbles.
Formal Syntax & Structure
javascript syntaxjavascript
event.composedReturn 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));})()