MCPcopy
hub / github.com/angular/angular / _queryNativeNodeDescendants

Function _queryNativeNodeDescendants

packages/core/src/debug/debug_node.ts:650–682  ·  view source on GitHub ↗

* Match all the descendants of a DOM node against a predicate. * * @param nativeNode the current native node * @param predicate the predicate to match * @param matches the list where matches are stored * @param elementsOnly whether only elements should be searched

(
  parentNode: any,
  predicate: Predicate<DebugElement> | Predicate<DebugNode>,
  matches: DebugElement[] | DebugNode[],
  elementsOnly: boolean,
)

Source from the content-addressed store, hash-verified

648 * @param elementsOnly whether only elements should be searched
649 */
650function _queryNativeNodeDescendants(
651 parentNode: any,
652 predicate: Predicate<DebugElement> | Predicate<DebugNode>,
653 matches: DebugElement[] | DebugNode[],
654 elementsOnly: boolean,
655) {
656 const nodes = parentNode.childNodes;
657 const length = nodes.length;
658
659 for (let i = 0; i < length; i++) {
660 const node = nodes[i];
661 const debugNode = getDebugNode(node);
662
663 if (debugNode) {
664 if (
665 elementsOnly &&
666 debugNode instanceof DebugElement &&
667 predicate(debugNode) &&
668 matches.indexOf(debugNode) === -1
669 ) {
670 matches.push(debugNode);
671 } else if (
672 !elementsOnly &&
673 (predicate as Predicate<DebugNode>)(debugNode) &&
674 (matches as DebugNode[]).indexOf(debugNode) === -1
675 ) {
676 (matches as DebugNode[]).push(debugNode);
677 }
678
679 _queryNativeNodeDescendants(node, predicate, matches, elementsOnly);
680 }
681 }
682}
683
684/**
685 * Iterates through the property bindings for a given node and generates

Callers 2

_queryAllFunction · 0.85
_queryNodeChildrenFunction · 0.85

Calls 4

getDebugNodeFunction · 0.85
indexOfMethod · 0.80
predicateFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…