| 304 | } |
| 305 | |
| 306 | export function findAllNodes( |
| 307 | hostRoot: Instance, |
| 308 | selectors: Array<Selector>, |
| 309 | ): Array<Instance> { |
| 310 | if (!supportsTestSelectors) { |
| 311 | throw new Error('Test selector API is not supported by this renderer.'); |
| 312 | } |
| 313 | |
| 314 | const root = findFiberRootForHostRoot(hostRoot); |
| 315 | const matchingFibers = findPaths(root, selectors); |
| 316 | |
| 317 | const instanceRoots: Array<Instance> = []; |
| 318 | |
| 319 | const stack = Array.from(matchingFibers); |
| 320 | let index = 0; |
| 321 | while (index < stack.length) { |
| 322 | const node = ((stack[index++]: any): Fiber); |
| 323 | const tag = node.tag; |
| 324 | if ( |
| 325 | tag === HostComponent || |
| 326 | tag === HostHoistable || |
| 327 | tag === HostSingleton |
| 328 | ) { |
| 329 | if (isHiddenSubtree(node)) { |
| 330 | continue; |
| 331 | } |
| 332 | instanceRoots.push(node.stateNode); |
| 333 | } else { |
| 334 | let child = node.child; |
| 335 | while (child !== null) { |
| 336 | stack.push(child); |
| 337 | child = child.sibling; |
| 338 | } |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | return instanceRoots; |
| 343 | } |
| 344 | |
| 345 | export function getFindAllNodesFailureDescription( |
| 346 | hostRoot: Instance, |