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

Function getFirstNativeNode

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

Source from the content-addressed store, hash-verified

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