@samitouri / QOS-React-1 / commits / e866b1d1e9

Add getRootNode to fabric fragment instance (#34544)

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.

Jack Pope committed Oct 3, 2025 at 09:48 UTC e866b1d1e9b8a1dc7a43f1be0c510784566b9bb1
1 file changed +18
packages/react-native-renderer/src/ReactFiberConfigFabric.js
+18
@@ -645,6 +645,9 @@ export type FragmentInstanceType = {
645 observeUsing: (observer: IntersectionObserver) => void,
646 unobserveUsing: (observer: IntersectionObserver) => void,
647 compareDocumentPosition: (otherNode: PublicInstance) => number,
648 + getRootNode(getRootNodeOptions?: {
649 + composed: boolean,
650 + }): Node | FragmentInstanceType,
651 };
652
653 function FragmentInstance(this: FragmentInstanceType, fragmentFiber: Fiber) {
@@ -754,6 +757,21 @@ function collectChildren(child: Fiber, collection: Array<Fiber>): boolean {
757 return false;
758 }
759
760 +// $FlowFixMe[prop-missing]
761 +FragmentInstance.prototype.getRootNode = function (
762 + this: FragmentInstanceType,
763 + getRootNodeOptions?: {composed: boolean},
764 +): Node | FragmentInstanceType {
765 + const parentHostFiber = getFragmentParentHostFiber(this._fragmentFiber);
766 + if (parentHostFiber === null) {
767 + return this;
768 + }
769 + const parentHostInstance = getPublicInstanceFromHostFiber(parentHostFiber);
770 + // $FlowFixMe[incompatible-use] Fabric PublicInstance is opaque
771 + const rootNode = (parentHostInstance.getRootNode(getRootNodeOptions): Node);
772 + return rootNode;
773 +};
774 +
775 export function createFragmentInstance(
776 fragmentFiber: Fiber,
777 ): FragmentInstanceType {