MCPcopy Create free account
hub / github.com/angular/angular / getFirstNativeNode

Function getFirstNativeNode

packages/core/src/render3/node_manipulation.ts:699–751  ·  view source on GitHub ↗
(lView: LView, tNode: TNode | null)

Source from the content-addressed store, hash-verified

697 * Native nodes are returned in the order in which those appear in the native tree (DOM).
698 */
699export function getFirstNativeNode(lView: LView, tNode: TNode | null): RNode | null {
700 if (tNode !== null) {
701 ngDevMode &&
702 assertTNodeType(
703 tNode,
704 TNodeType.AnyRNode |
705 TNodeType.AnyContainer |
706 TNodeType.Icu |
707 TNodeType.Projection |
708 TNodeType.LetDeclaration,
709 );
710
711 const tNodeType = tNode.type;
712 if (tNodeType & TNodeType.AnyRNode) {
713 return getNativeByTNode(tNode, lView);
714 } else if (tNodeType & TNodeType.Container) {
715 return getBeforeNodeForView(-1, lView[tNode.index]);
716 } else if (tNodeType & TNodeType.ElementContainer) {
717 const elIcuContainerChild = tNode.child;
718 if (elIcuContainerChild !== null) {
719 return getFirstNativeNode(lView, elIcuContainerChild);
720 } else {
721 const rNodeOrLContainer = lView[tNode.index];
722 if (isLContainer(rNodeOrLContainer)) {
723 return getBeforeNodeForView(-1, rNodeOrLContainer);
724 } else {
725 return unwrapRNode(rNodeOrLContainer);
726 }
727 }
728 } else if (tNodeType & TNodeType.LetDeclaration) {
729 return getFirstNativeNode(lView, tNode.next);
730 } else if (tNodeType & TNodeType.Icu) {
731 let nextRNode = icuContainerIterate(tNode as TIcuContainerNode, lView);
732 let rNode: RNode | null = nextRNode();
733 // If the ICU container has no nodes, than we use the ICU anchor as the node.
734 return rNode || unwrapRNode(lView[tNode.index]);
735 } else {
736 const projectionNodes = getProjectionNodes(lView, tNode);
737 if (projectionNodes !== null) {
738 if (Array.isArray(projectionNodes)) {
739 return projectionNodes[0];
740 }
741 const parentView = getLViewParent(lView[DECLARATION_COMPONENT_VIEW]);
742 ngDevMode && assertParentView(parentView);
743 return getFirstNativeNode(parentView!, projectionNodes);
744 } else {
745 return getFirstNativeNode(lView, tNode.next);
746 }
747 }
748 }
749
750 return null;
751}
752
753export function getProjectionNodes(lView: LView, tNode: TNode | null): TNode | RNode[] | null {
754 if (tNode !== null) {

Callers 3

calcPathForNodeFunction · 0.90
getBeforeNodeForViewFunction · 0.85

Calls 10

assertTNodeTypeFunction · 0.90
getNativeByTNodeFunction · 0.90
isLContainerFunction · 0.90
unwrapRNodeFunction · 0.90
icuContainerIterateFunction · 0.90
getLViewParentFunction · 0.90
assertParentViewFunction · 0.90
getBeforeNodeForViewFunction · 0.85
getProjectionNodesFunction · 0.85
isArrayMethod · 0.80

Tested by

no test coverage detected