Skip to content

Conversation

jackpope
Copy link
Contributor

The root instance doesn't have a canonical property so we were not returning a public instance that we can call compareDocumentPosition on when a Fragment had no other host parent in Fabric. In this case we need to get the ReactNativeElement from the ReactNativeDocument.

I've also added test coverage for this case in DOM for consistency, though it was already working there because we use DOM elements as root. This same test will be copied to RN using Fantom.

@react-sizebot
Copy link

react-sizebot commented Sep 19, 2025

Comparing: 01cad9e...03e3d6f

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.68 kB 6.68 kB +0.11% 1.82 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 534.28 kB 534.28 kB = 94.31 kB 94.31 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB +0.11% 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 663.59 kB 663.59 kB = 116.98 kB 116.98 kB
facebook-www/ReactDOM-prod.classic.js = 687.51 kB 687.51 kB = 121.00 kB 121.01 kB
facebook-www/ReactDOM-prod.modern.js = 677.93 kB 677.93 kB = 119.36 kB 119.36 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against 03e3d6f

… in Fabric

The root instance doesn't have a canonical property so we were not returning a public instance that we can call compareDocumentPosition on when a Fragment had no other host parent in Fabric. In this case we need to get the ReactNativeElement from the ReactNativeDocument.

I've also added test coverage for this case in DOM for consistency, though it was already working there because we use DOM elements as root.
Comment on lines +306 to +310
if (instance.containerInfo != null) {
if (instance.containerInfo.publicInstance != null) {
return instance.containerInfo.publicInstance;
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively if theres a concern with allowing this on all getPublicInstance calls we can move this logic to the callsite in compareDocumentInstance

@jackpope jackpope merged commit 83c88ad into facebook:main Sep 23, 2025
241 checks passed
@jackpope jackpope deleted the root-fr-fabric branch September 23, 2025 14:56
github-actions bot pushed a commit that referenced this pull request Sep 23, 2025
The root instance doesn't have a canonical property so we were not
returning a public instance that we can call compareDocumentPosition on
when a Fragment had no other host parent in Fabric. In this case we need
to get the ReactNativeElement from the ReactNativeDocument.

I've also added test coverage for this case in DOM for consistency,
though it was already working there because we use DOM elements as root.
This same test will be copied to RN using Fantom.

DiffTrain build for [83c88ad](83c88ad)
jackpope added a commit that referenced this pull request Oct 3, 2025
Stacked on #34533 for root fragment handling

This is the same approach as DOM, where we call getRootNode on the
parent.
    
Tests are in react-native using Fantom.
github-actions bot pushed a commit that referenced this pull request Oct 3, 2025
Stacked on #34533 for root fragment handling

This is the same approach as DOM, where we call getRootNode on the
parent.

Tests are in react-native using Fantom.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants