MCPcopy Index your code
hub / github.com/angular/angular / _addQueryMatch

Function _addQueryMatch

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

* Match the current native node against the predicate. * * @param nativeNode the current native node * @param predicate the predicate to match * @param matches the list of positive matches * @param elementsOnly whether only elements should be searched * @param rootNativeNode the root native no

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

Source from the content-addressed store, hash-verified

608 * @param rootNativeNode the root native node on which predicate should not be matched
609 */
610function _addQueryMatch(
611 nativeNode: any,
612 predicate: Predicate<DebugElement> | Predicate<DebugNode>,
613 matches: DebugElement[] | DebugNode[],
614 elementsOnly: boolean,
615 rootNativeNode: any,
616) {
617 if (rootNativeNode !== nativeNode) {
618 const debugNode = getDebugNode(nativeNode);
619 if (!debugNode) {
620 return;
621 }
622 // Type of the "predicate and "matches" array are set based on the value of
623 // the "elementsOnly" parameter. TypeScript is not able to properly infer these
624 // types with generics, so we manually cast the parameters accordingly.
625 if (
626 elementsOnly &&
627 debugNode instanceof DebugElement &&
628 predicate(debugNode) &&
629 matches.indexOf(debugNode) === -1
630 ) {
631 matches.push(debugNode);
632 } else if (
633 !elementsOnly &&
634 (predicate as Predicate<DebugNode>)(debugNode) &&
635 (matches as DebugNode[]).indexOf(debugNode) === -1
636 ) {
637 (matches as DebugNode[]).push(debugNode);
638 }
639 }
640}
641
642/**
643 * Match all the descendants of a DOM node against a predicate.

Callers 1

_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…