Custom Elements Connected Signal
- Category
- Web Components
- Type
- New or changed feature
- Status
- Proposed (Chrome Proposed)
- Intent stage
- None
Summary
This feature proposes `ElementInternals#connectedSignal` which is an `AbortSignal` created when the element is connected to the DOM and aborted when the element disconnects from the DOM.
Motivation
A common technique for Custom Element authors is add event listeners or fetch requests that are attached to the connected state of an element - typically by passing in an AbortController Signal which is aborted on disconnectedCallback. It can be a little cumbersome to set up such an AbortController, and would simplify ergonomics if Custom Elements had a built-in AbortSignal that represented the connected state.
Standards & signals
- Firefox: No signal
- Safari: No signal
- Web developers: No signals
- Tracking bug: https://issues.chromium.org/issues/349291150
Ecosystem
- Web Platform Tests: https://wpt.fyi/results/?q=custom-elements-connected-signal
- Chrome Platform Showcase: https://chrome-platform-showcase.paulkinlan-ea.deno.net/features
- GenDN reference: https://gendn.paulkinlan-ea.deno.net/features
- chrome.dev demos search: https://www.google.com/search?q=site%3Achrome.dev+Custom%20Elements%20Connected%20Signal
- MDN Web Docs: https://developer.mozilla.org/en-US/search?q=Custom%20Elements%20Connected%20Signal
- Baseline status: https://webstatus.dev/?q=Custom%20Elements%20Connected%20Signal
Explainers: https://github.com/whatwg/html/issues/9881