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

Function appendChild

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

Source from the content-addressed store, hash-verified

644 * @param childTNode The TNode of the child element
645 */
646export function appendChild(
647 tView: TView,
648 lView: LView,
649 childRNode: RNode | RNode[],
650 childTNode: TNode,
651): void {
652 const parentRNode = getParentRElement(tView, childTNode, lView);
653 const renderer = lView[RENDERER];
654 const parentTNode: TNode = childTNode.parent || lView[T_HOST]!;
655 const anchorNode = getInsertInFrontOfRNode(parentTNode, childTNode, lView);
656 if (parentRNode != null) {
657 if (Array.isArray(childRNode)) {
658 for (let i = 0; i < childRNode.length; i++) {
659 nativeAppendOrInsertBefore(renderer, parentRNode, childRNode[i], anchorNode, false);
660 }
661 } else {
662 nativeAppendOrInsertBefore(renderer, parentRNode, childRNode, anchorNode, false);
663 }
664 }
665
666 _processI18nInsertBefore !== undefined &&
667 _processI18nInsertBefore(renderer, childTNode, lView, childRNode, parentRNode);
668}
669
670/**
671 * 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