Skip to content

Unobserve removed Fragment children - #37452

Closed
OskarEichler wants to merge 1 commit into
react:mainfrom
OskarEichler:fix/react-dom-unobserve-removed-fragment-children
Closed

Unobserve removed Fragment children#37452
OskarEichler wants to merge 1 commit into
react:mainfrom
OskarEichler:fix/react-dom-unobserve-removed-fragment-children

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

  • Unobserve removed Fragment element children from every registered observer.
  • Mirror the existing insertion behavior while continuing to skip text children.
  • Strengthen the dynamic-child regression with the exact removed node assertion.

Breaking changes

None. Fragment refs remain experimental/gated; this completes expected observer cleanup.

Verification

  • Full ReactDOMFragmentRefs suites: 90 tests passed.
  • DOM-node Flow, targeted ESLint, Prettier, and git diff --check passed.

Fixes #37451

@meta-cla meta-cla Bot added the CLA Signed label Aug 30, 2026
@github-actions

Copy link
Copy Markdown

A size report will appear here when the build finishes.

Generated by sizebot against bc41a79

jackpope added a commit that referenced this pull request Aug 31, 2026
)

Fragment IntersectionObserver targets used to stay observed after a
child was removed so the exit record (isIntersecting: false) could still
fire, but that left the observer holding detached nodes. We now
unobserve ResizeObserver targets immediately, and delay
IntersectionObserver unobserve until after paint so the exit still
lands, then drop the strong ref.

If the same node is reinserted before that flush, we cancel the pending
unobserve so a later cleanup does not detach a child that’s still
visible.

Closes #37452
Closes #37302
Fixes #37451
github-actions Bot pushed a commit that referenced this pull request Aug 31, 2026
)

Fragment IntersectionObserver targets used to stay observed after a
child was removed so the exit record (isIntersecting: false) could still
fire, but that left the observer holding detached nodes. We now
unobserve ResizeObserver targets immediately, and delay
IntersectionObserver unobserve until after paint so the exit still
lands, then drop the strong ref.

If the same node is reinserted before that flush, we cancel the pending
unobserve so a later cleanup does not detach a child that’s still
visible.

Closes #37452
Closes #37302
Fixes #37451

DiffTrain build for [065bc84](065bc84)
github-actions Bot pushed a commit that referenced this pull request Aug 31, 2026
)

Fragment IntersectionObserver targets used to stay observed after a
child was removed so the exit record (isIntersecting: false) could still
fire, but that left the observer holding detached nodes. We now
unobserve ResizeObserver targets immediately, and delay
IntersectionObserver unobserve until after paint so the exit still
lands, then drop the strong ref.

If the same node is reinserted before that flush, we cancel the pending
unobserve so a later cleanup does not detach a child that’s still
visible.

Closes #37452
Closes #37302
Fixes #37451

DiffTrain build for [065bc84](065bc84)
github-actions Bot pushed a commit to code/lib-react that referenced this pull request Aug 31, 2026
…ct#37408)

Fragment IntersectionObserver targets used to stay observed after a
child was removed so the exit record (isIntersecting: false) could still
fire, but that left the observer holding detached nodes. We now
unobserve ResizeObserver targets immediately, and delay
IntersectionObserver unobserve until after paint so the exit still
lands, then drop the strong ref.

If the same node is reinserted before that flush, we cancel the pending
unobserve so a later cleanup does not detach a child that’s still
visible.

Closes react#37452
Closes react#37302
Fixes react#37451

DiffTrain build for [065bc84](react@065bc84)
github-actions Bot pushed a commit to code/lib-react that referenced this pull request Aug 31, 2026
…ct#37408)

Fragment IntersectionObserver targets used to stay observed after a
child was removed so the exit record (isIntersecting: false) could still
fire, but that left the observer holding detached nodes. We now
unobserve ResizeObserver targets immediately, and delay
IntersectionObserver unobserve until after paint so the exit still
lands, then drop the strong ref.

If the same node is reinserted before that flush, we cancel the pending
unobserve so a later cleanup does not detach a child that’s still
visible.

Closes react#37452
Closes react#37302
Fixes react#37451

DiffTrain build for [065bc84](react@065bc84)
github-actions Bot pushed a commit to srpatcha/react that referenced this pull request Sep 1, 2026
…ct#37408)

Fragment IntersectionObserver targets used to stay observed after a
child was removed so the exit record (isIntersecting: false) could still
fire, but that left the observer holding detached nodes. We now
unobserve ResizeObserver targets immediately, and delay
IntersectionObserver unobserve until after paint so the exit still
lands, then drop the strong ref.

If the same node is reinserted before that flush, we cancel the pending
unobserve so a later cleanup does not detach a child that’s still
visible.

Closes react#37452
Closes react#37302
Fixes react#37451

DiffTrain build for [065bc84](react@065bc84)
github-actions Bot pushed a commit to srpatcha/react that referenced this pull request Sep 1, 2026
…ct#37408)

Fragment IntersectionObserver targets used to stay observed after a
child was removed so the exit record (isIntersecting: false) could still
fire, but that left the observer holding detached nodes. We now
unobserve ResizeObserver targets immediately, and delay
IntersectionObserver unobserve until after paint so the exit still
lands, then drop the strong ref.

If the same node is reinserted before that flush, we cancel the pending
unobserve so a later cleanup does not detach a child that’s still
visible.

Closes react#37452
Closes react#37302
Fixes react#37451

DiffTrain build for [065bc84](react@065bc84)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

1 participant