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

Function getFirstNativeNode

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

Source from the content-addressed store, hash-verified

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