CustomEvent & dispatch Playground

Rara sends a note out of the kartu-produk component: set your CustomEvent’s bubbles and composed, see how far it gets out of the shadow root, and every…

Why it matters

Pub/sub for free from the DOM: components talk without importing each other. The basis of Web Components and many vanilla libraries. Get one option wrong (bubbles, composed, cancelable, detail) and the event seems sent, but nobody hears it, or the data is gone.

The key idea

Emit without knowing who listens, and it all runs inside dispatchEvent

Common mistakes

Try it in this playground