( tView: TView, lView: LView, tNode: TNode | null, result: any[], isProjection: boolean = false, )
| 26 | import {getLViewParent, unwrapRNode} from './util/view_utils'; |
| 27 | |
| 28 | export function collectNativeNodes( |
| 29 | tView: TView, |
| 30 | lView: LView, |
| 31 | tNode: TNode | null, |
| 32 | result: any[], |
| 33 | isProjection: boolean = false, |
| 34 | ): any[] { |
| 35 | if (tView.type === TViewType.Foreign) { |
| 36 | const headTNode = tView.firstChild!; |
| 37 | const tailTNode = headTNode.next!; |
| 38 | const head = unwrapRNode(lView[headTNode.index]); |
| 39 | const tail = unwrapRNode(lView[tailTNode.index]); |
| 40 | |
| 41 | let current: RNode | null = head; |
| 42 | while (current !== null) { |
| 43 | result.push(current); |
| 44 | if (current === tail) break; |
| 45 | current = current.nextSibling; |
| 46 | } |
| 47 | return result; |
| 48 | } |
| 49 | |
| 50 | while (tNode !== null) { |
| 51 | // Let declarations don't have corresponding DOM nodes so we skip over them. |
| 52 | if (tNode.type === TNodeType.LetDeclaration) { |
| 53 | tNode = isProjection ? tNode.projectionNext : tNode.next; |
| 54 | continue; |
| 55 | } |
| 56 | |
| 57 | ngDevMode && |
| 58 | assertTNodeType( |
| 59 | tNode, |
| 60 | TNodeType.AnyRNode | TNodeType.AnyContainer | TNodeType.Projection | TNodeType.Icu, |
| 61 | ); |
| 62 | |
| 63 | const lNode = lView[tNode.index]; |
| 64 | if (lNode !== null) { |
| 65 | if (isLContainer(lNode)) { |
| 66 | const anchor = lNode[NATIVE]; |
| 67 | // If this is a dynamic container (ViewContainerRef on an element), the HOST element is a |
| 68 | // distinct element node and must be pushed first (before the views are collected) to |
| 69 | // preserve DOM order. |
| 70 | if (anchor !== lNode[HOST]) { |
| 71 | result.push(unwrapRNode(lNode)); |
| 72 | } |
| 73 | |
| 74 | // Collect the root nodes from the views in this container. |
| 75 | if (!(lNode[FLAGS] & LContainerFlags.LogicalOnly)) { |
| 76 | collectNativeNodesInLContainer(lNode, result); |
| 77 | } |
| 78 | |
| 79 | // The container's anchor comment node is always physically positioned after any views |
| 80 | // rendered inside the container, so we always push it here at the end. |
| 81 | result.push(anchor); |
| 82 | } else { |
| 83 | result.push(unwrapRNode(lNode)); |
| 84 | } |
| 85 | } |
no test coverage detected