* 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, )
| 608 | * @param rootNativeNode the root native node on which predicate should not be matched |
| 609 | */ |
| 610 | function _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. |
no test coverage detected
searching dependent graphs…