Files
Viktor 9b93853278 [DOM] Fix Fragment compareDocumentPosition for the root container (#37613)
## Summary

`FragmentInstance.compareDocumentPosition()` returns
`DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC` instead of `CONTAINS |
PRECEDING` for the container passed to `createRoot()`, and for any
element between that container and `document.body`:

```js
const container = document.getElementById('root');
createRoot(container).render(<div><Fragment ref={ref}><div /></Fragment></div>);

ref.current.compareDocumentPosition(document.body); // contains
ref.current.compareDocumentPosition(container);     // implementationSpecific
```

The `CONTAINS` fiber validation enumerates the nodes that have no fiber
as `document`, `documentElement` and `body`. That list is never
complete: the root container has no fiber either, and neither does any
non-React element above it, so both fall through and are reported as
implementation specific.

This checks that `otherNode` contains the root container instead, which
covers all of those uniformly.

Adjacent to #37579, which fixed a `null` dereference in the same branch.
2026-09-14 13:24:59 +02:00
..