← Back to release summary

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

Ecosystem

Explainers: https://github.com/whatwg/html/issues/9881

View on chromestatus.com