MCPcopy Index your code
hub / github.com/react/react / hasMatchingPaths

Function hasMatchingPaths

packages/react-reconciler/src/ReactTestSelectors.js:269–304  ·  view source on GitHub ↗
(root: Fiber, selectors: Array<Selector>)

Source from the content-addressed store, hash-verified

267
268// Same as findPaths but with eager bailout on first match
269function hasMatchingPaths(root: Fiber, selectors: Array<Selector>): boolean {
270 const stack = [root, 0];
271 let index = 0;
272 while (index < stack.length) {
273 const fiber = ((stack[index++]: any): Fiber);
274 const tag = fiber.tag;
275 let selectorIndex = ((stack[index++]: any): number);
276 let selector = selectors[selectorIndex];
277
278 if (
279 (tag === HostComponent ||
280 tag === HostHoistable ||
281 tag === HostSingleton) &&
282 isHiddenSubtree(fiber)
283 ) {
284 continue;
285 } else {
286 while (selector != null && matchSelector(fiber, selector)) {
287 selectorIndex++;
288 selector = selectors[selectorIndex];
289 }
290 }
291
292 if (selectorIndex === selectors.length) {
293 return true;
294 } else {
295 let child = fiber.child;
296 while (child !== null) {
297 stack.push(child, selectorIndex);
298 child = child.sibling;
299 }
300 }
301 }
302
303 return false;
304}
305
306export function findAllNodes(
307 hostRoot: Instance,

Callers 1

matchSelectorFunction · 0.85

Calls 3

isHiddenSubtreeFunction · 0.90
matchSelectorFunction · 0.85
pushMethod · 0.65

Tested by

no test coverage detected