( tView: TView, lView: LView, tNode: TNode | null, result: any[], isProjection: boolean = false, )
| 18 | import {getLViewParent, unwrapRNode} from './util/view_utils'; |
| 19 | |
| 20 | export function collectNativeNodes( |
| 21 | tView: TView, |
| 22 | lView: LView, |
| 23 | tNode: TNode | null, |
| 24 | result: any[], |
| 25 | isProjection: boolean = false, |
| 26 | ): any[] { |
| 27 | while (tNode !== null) { |
| 28 | // Let declarations don't have corresponding DOM nodes so we skip over them. |
| 29 | if (tNode.type === TNodeType.LetDeclaration) { |
| 30 | tNode = isProjection ? tNode.projectionNext : tNode.next; |
| 31 | continue; |
| 32 | } |
| 33 | |
| 34 | ngDevMode && |
| 35 | assertTNodeType( |
| 36 | tNode, |
| 37 | TNodeType.AnyRNode | TNodeType.AnyContainer | TNodeType.Projection | TNodeType.Icu, |
| 38 | ); |
| 39 | |
| 40 | const lNode = lView[tNode.index]; |
| 41 | if (lNode !== null) { |
| 42 | result.push(unwrapRNode(lNode)); |
| 43 | } |
| 44 | |
| 45 | // A given lNode can represent either a native node or a LContainer (when it is a host of a |
| 46 | // ViewContainerRef). When we find a LContainer we need to descend into it to collect root nodes |
| 47 | // from the views in this container. |
| 48 | if (isLContainer(lNode)) { |
| 49 | collectNativeNodesInLContainer(lNode, result); |
| 50 | } |
| 51 | |
| 52 | const tNodeType = tNode.type; |
| 53 | if (tNodeType & TNodeType.ElementContainer) { |
| 54 | collectNativeNodes(tView, lView, tNode.child, result); |
| 55 | } else if (tNodeType & TNodeType.Icu) { |
| 56 | const nextRNode = icuContainerIterate(tNode as TIcuContainerNode, lView); |
| 57 | let rNode: RNode | null; |
| 58 | while ((rNode = nextRNode())) { |
| 59 | result.push(rNode); |
| 60 | } |
| 61 | } else if (tNodeType & TNodeType.Projection) { |
| 62 | const nodesInSlot = getProjectionNodes(lView, tNode); |
| 63 | if (Array.isArray(nodesInSlot)) { |
| 64 | result.push(...nodesInSlot); |
| 65 | } else { |
| 66 | const parentView = getLViewParent(lView[DECLARATION_COMPONENT_VIEW])!; |
| 67 | ngDevMode && assertParentView(parentView); |
| 68 | collectNativeNodes(parentView[TVIEW], parentView, nodesInSlot, result, true); |
| 69 | } |
| 70 | } |
| 71 | tNode = isProjection ? tNode.projectionNext : tNode.next; |
| 72 | } |
| 73 | |
| 74 | return result; |
| 75 | } |
| 76 | |
| 77 | /** |
no test coverage detected
searching dependent graphs…