mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 00:20:04 +01:00
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.
This commit is contained in:
parent
19f65ff179
commit
e866b1d1e9
|
|
@ -645,6 +645,9 @@ export type FragmentInstanceType = {
|
|||
observeUsing: (observer: IntersectionObserver) => void,
|
||||
unobserveUsing: (observer: IntersectionObserver) => void,
|
||||
compareDocumentPosition: (otherNode: PublicInstance) => number,
|
||||
getRootNode(getRootNodeOptions?: {
|
||||
composed: boolean,
|
||||
}): Node | FragmentInstanceType,
|
||||
};
|
||||
|
||||
function FragmentInstance(this: FragmentInstanceType, fragmentFiber: Fiber) {
|
||||
|
|
@ -754,6 +757,21 @@ function collectChildren(child: Fiber, collection: Array<Fiber>): boolean {
|
|||
return false;
|
||||
}
|
||||
|
||||
// $FlowFixMe[prop-missing]
|
||||
FragmentInstance.prototype.getRootNode = function (
|
||||
this: FragmentInstanceType,
|
||||
getRootNodeOptions?: {composed: boolean},
|
||||
): Node | FragmentInstanceType {
|
||||
const parentHostFiber = getFragmentParentHostFiber(this._fragmentFiber);
|
||||
if (parentHostFiber === null) {
|
||||
return this;
|
||||
}
|
||||
const parentHostInstance = getPublicInstanceFromHostFiber(parentHostFiber);
|
||||
// $FlowFixMe[incompatible-use] Fabric PublicInstance is opaque
|
||||
const rootNode = (parentHostInstance.getRootNode(getRootNodeOptions): Node);
|
||||
return rootNode;
|
||||
};
|
||||
|
||||
export function createFragmentInstance(
|
||||
fragmentFiber: Fiber,
|
||||
): FragmentInstanceType {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user