Repository navigation
Conversation
|
this is quite possibly the best thing ever in a while, I can't wait to make all my libraries deprecated once this land, huge thanks to anyone involved 🙏 |
annevk
force-pushed
the
annevk/transient-registered-observers
branch
from
October 8, 2026 09:46
f5f5f6e to
ada81c8
Compare
annevk
force-pushed
the
annevk/observe-connectedness
branch
from
October 8, 2026 09:47
0dbc504 to
7bdca97
Compare
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. That puts them before the tree mutation record for the insertion or removal that caused them, also when that record is queued later, such as for replaceChildren(). 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.
annevk
force-pushed
the
annevk/observe-connectedness
branch
from
October 9, 2026 14:11
7e8a5c8 to
811f16d
Compare
|
@WebReflection Well, not all libraries, we will need a polyfill in the first years :) |
Contributor
|
We've looked at the use cases for this posted in the issue and it seems useful. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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. That puts
them before the tree mutation record for the insertion or removal that
caused them, also when that record is queued later, such as for
replaceChildren(). 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: web-platform-tests/wpt#63396
(See WHATWG Working Mode: Changes for more details.)
Preview | Diff