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

Function appendChild

packages/core/src/render3/node_manipulation.ts:671–693  ·  view source on GitHub ↗
(
  tView: TView,
  lView: LView,
  childRNode: RNode | RNode[],
  childTNode: TNode,
)

Source from the content-addressed store, hash-verified

669 * @param childTNode The TNode of the child element
670 */
671export function appendChild(
672 tView: TView,
673 lView: LView,
674 childRNode: RNode | RNode[],
675 childTNode: TNode,
676): void {
677 const parentRNode = getParentRElement(tView, childTNode, lView);
678 const renderer = lView[RENDERER];
679 const parentTNode: TNode = childTNode.parent || lView[T_HOST]!;
680 const anchorNode = getInsertInFrontOfRNode(parentTNode, childTNode, lView);
681 if (parentRNode != null) {
682 if (Array.isArray(childRNode)) {
683 for (let i = 0; i < childRNode.length; i++) {
684 nativeAppendOrInsertBefore(renderer, parentRNode, childRNode[i], anchorNode, false);
685 }
686 } else {
687 nativeAppendOrInsertBefore(renderer, parentRNode, childRNode, anchorNode, false);
688 }
689 }
690
691 _processI18nInsertBefore !== undefined &&
692 _processI18nInsertBefore(renderer, childTNode, lView, childRNode, parentRNode);
693}
694
695/**
696 * Returns the first native node for a given LView, starting from the provided TNode.

Callers 4

ɵɵtextFunction · 0.90
elementLikeStartSharedFunction · 0.90
ɵɵforeignComponentFunction · 0.90
templateCreateFunction · 0.90

Calls 4

getParentRElementFunction · 0.85
getInsertInFrontOfRNodeFunction · 0.85
isArrayMethod · 0.80

Tested by

no test coverage detected