(hostRoot: Instance)
| 118 | } |
| 119 | |
| 120 | function findFiberRootForHostRoot(hostRoot: Instance): Fiber { |
| 121 | const maybeFiber = getInstanceFromNode((hostRoot: any)); |
| 122 | if (maybeFiber != null) { |
| 123 | if (typeof maybeFiber.memoizedProps['data-testname'] !== 'string') { |
| 124 | throw new Error( |
| 125 | 'Invalid host root specified. Should be either a React container or a node with a testname attribute.', |
| 126 | ); |
| 127 | } |
| 128 | |
| 129 | return ((maybeFiber: any): Fiber); |
| 130 | } else { |
| 131 | const fiberRoot = findFiberRoot(hostRoot); |
| 132 | |
| 133 | if (fiberRoot === null) { |
| 134 | throw new Error( |
| 135 | 'Could not find React container within specified host subtree.', |
| 136 | ); |
| 137 | } |
| 138 | |
| 139 | // The Flow type for FiberRoot is a little funky. |
| 140 | // createFiberRoot() cheats this by treating the root as :any and adding stateNode lazily. |
| 141 | return ((fiberRoot: any).stateNode.current: Fiber); |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | function matchSelector(fiber: Fiber, selector: Selector): boolean { |
| 146 | const tag = fiber.tag; |
no test coverage detected