Every DOM event dispatch has a capture phase that travels from the window down through each ancestor to the target before the event bubbles back up. Listeners only run during capture if you register them with { capture: true } (or true as the third argument). Capturing is useful when an ancestor must see an event before descendants can react or stop it.
<div id="outer">
<button id="btn">Click</button>
</div>
const log = (label) => () => console.log(label);
outer.addEventListener('click', log('outer capture'), { capture: true });
outer.addEventListener('click', log('outer bubble'));
btn.addEventListener('click', log('button'));
// Click the button:
// outer capture → button → outer bubble
The dispatch path is computed once, when dispatch starts: window → document → <html> → <body> → #outer → #btn. The event then:
capture: true.event.bubbles is true.focus, blur, mouseenter, load on images and scroll on elements do not bubble, but they do go through the capture phase. A single capturing listener on a container can therefore observe focus for all descendants (or use focusin/focusout, which bubble).document, so a child calling stopPropagation() in its bubble handler cannot hide the event.stopPropagation() to prevent descendants from ever receiving an event, for example to block interaction while a section is disabled. Use this sparingly, because it is invisible to whoever maintains the child code.// Close a popover on any outside pointer down, even if inner code stops propagation
document.addEventListener('pointerdown', (e) => {
if (!popover.contains(e.target)) closePopover();
}, { capture: true });
removeEventListener('click', fn) does not remove a listener added with { capture: true }. You must pass { capture: true } again, because capture is part of the listener's identity. (once/passive are not.)e.target and returning early.onClickCapture etc. Since React 17, React attaches its listeners to the root container rather than document, so native capture listeners on document still run before React's.event.eventPhase being 1, 2 or 3.Spotted a mistake or a rights concern? Report an issue