(lView: LView, tNode: TNode | null)
| 667 | * Native nodes are returned in the order in which those appear in the native tree (DOM). |
| 668 | */ |
| 669 | export function getFirstNativeNode(lView: LView, tNode: TNode | null): RNode | null { |
| 670 | if (tNode !== null) { |
| 671 | ngDevMode && |
| 672 | assertTNodeType( |
| 673 | tNode, |
| 674 | TNodeType.AnyRNode | |
| 675 | TNodeType.AnyContainer | |
| 676 | TNodeType.Icu | |
| 677 | TNodeType.Projection | |
| 678 | TNodeType.LetDeclaration, |
| 679 | ); |
| 680 | |
| 681 | const tNodeType = tNode.type; |
| 682 | if (tNodeType & TNodeType.AnyRNode) { |
| 683 | return getNativeByTNode(tNode, lView); |
| 684 | } else if (tNodeType & TNodeType.Container) { |
| 685 | return getBeforeNodeForView(-1, lView[tNode.index]); |
| 686 | } else if (tNodeType & TNodeType.ElementContainer) { |
| 687 | const elIcuContainerChild = tNode.child; |
| 688 | if (elIcuContainerChild !== null) { |
| 689 | return getFirstNativeNode(lView, elIcuContainerChild); |
| 690 | } else { |
| 691 | const rNodeOrLContainer = lView[tNode.index]; |
| 692 | if (isLContainer(rNodeOrLContainer)) { |
| 693 | return getBeforeNodeForView(-1, rNodeOrLContainer); |
| 694 | } else { |
| 695 | return unwrapRNode(rNodeOrLContainer); |
| 696 | } |
| 697 | } |
| 698 | } else if (tNodeType & TNodeType.LetDeclaration) { |
| 699 | return getFirstNativeNode(lView, tNode.next); |
| 700 | } else if (tNodeType & TNodeType.Icu) { |
| 701 | let nextRNode = icuContainerIterate(tNode as TIcuContainerNode, lView); |
| 702 | let rNode: RNode | null = nextRNode(); |
| 703 | // If the ICU container has no nodes, than we use the ICU anchor as the node. |
| 704 | return rNode || unwrapRNode(lView[tNode.index]); |
| 705 | } else { |
| 706 | const projectionNodes = getProjectionNodes(lView, tNode); |
| 707 | if (projectionNodes !== null) { |
| 708 | if (Array.isArray(projectionNodes)) { |
| 709 | return projectionNodes[0]; |
| 710 | } |
| 711 | const parentView = getLViewParent(lView[DECLARATION_COMPONENT_VIEW]); |
| 712 | ngDevMode && assertParentView(parentView); |
| 713 | return getFirstNativeNode(parentView!, projectionNodes); |
| 714 | } else { |
| 715 | return getFirstNativeNode(lView, tNode.next); |
| 716 | } |
| 717 | } |
| 718 | } |
| 719 | |
| 720 | return null; |
| 721 | } |
| 722 | |
| 723 | export function getProjectionNodes(lView: LView, tNode: TNode | null): TNode | RNode[] | null { |
| 724 | if (tNode !== null) { |
no test coverage detected
searching dependent graphs…