- From: Anne van Kesteren <notifications@github.com>
- Date: Thu, 08 Oct 2026 01:47:44 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/pull/1508@github.com>
Add a connectedness member to MutationObserverInit. When it is true,
the observer gets a "connected" or "disconnected" record each time the
target becomes connected or stops being connected, including when that
happens because an ancestor or shadow host is inserted or removed. The
subtree member does not apply to connectedness, as that would require
a record for each node of an inserted or removed subtree.
These records are queued where the connectedCallback and
disconnectedCallback custom element reactions are enqueued. The move
algorithm does not queue them as it cannot change whether a node is
connected.
As this makes it natural to observe many individual nodes with a
single MutationObserver object, also add unobserve(target), which
stops observing target as requested through observe() without
affecting other targets. Unlike disconnect(), it does not empty the
record queue, as a record can be the result of multiple registered
observers. This matches IntersectionObserver's unobserve().
Fixes #126. Fixes #533.
Tests: https://github.com/web-platform-tests/wpt/pull/63396
Depends on #1507. This targets the branch of that PR until it lands.
- [ ] At least two implementers are interested (and none opposed):
* …
* …
- [x] [Tests](https://github.com/web-platform-tests/wpt) are written and can be reviewed and commented upon at:
* https://github.com/web-platform-tests/wpt/pull/63396
- [ ] [Implementation bugs](https://github.com/whatwg/meta/blob/main/MAINTAINERS.md#handling-pull-requests) are filed:
* Chromium: …
* Gecko: …
* WebKit: …
* Deno (only for aborting and events): …
* Node.js (only for aborting and events): …
- [ ] [MDN issue](https://github.com/whatwg/meta/blob/main/MAINTAINERS.md#handling-pull-requests) is filed: …
- [x] The top of this comment includes a [clear commit message](https://github.com/whatwg/meta/blob/main/COMMITTING.md) to use.
(See [WHATWG Working Mode: Changes](https://whatwg.org/working-mode#changes) for more details.)
You can view, comment on, or merge this pull request online at:
https://github.com/whatwg/dom/pull/1508
-- Commit Summary --
* Allow MutationObserver to observe connectedness and add unobserve()
-- File Changes --
M dom.bs (121)
-- Patch Links --
https://github.com/whatwg/dom/pull/1508.patch
https://github.com/whatwg/dom/pull/1508.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/pull/1508
You are receiving this because you are subscribed to this thread.
Message ID: <whatwg/dom/pull/1508@github.com>
Received on Thursday, 8 October 2026 08:47:48 UTC