MCPcopy Index your code
hub / github.com/angular/angular / getFirstNativeNode

Function getFirstNativeNode

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

Source from the content-addressed store, hash-verified

667 * Native nodes are returned in the order in which those appear in the native tree (DOM).
668 */
669export 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
723export function getProjectionNodes(lView: LView, tNode: TNode | null): TNode | RNode[] | null {
724 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…