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

Function createAnchorNode

packages/core/src/linker/view_container_ref.ts:768–788  ·  view source on GitHub ↗

* Regular creation mode: an anchor is created and * assigned to the `lContainer[NATIVE]` slot.

(
  lContainer: LContainer,
  hostLView: LView,
  hostTNode: TNode,
  slotValue: any,
)

Source from the content-addressed store, hash-verified

766 * assigned to the `lContainer[NATIVE]` slot.
767 */
768function createAnchorNode(
769 lContainer: LContainer,
770 hostLView: LView,
771 hostTNode: TNode,
772 slotValue: any,
773) {
774 // We already have a native element (anchor) set, return.
775 if (lContainer[NATIVE]) return;
776
777 let commentNode: RComment;
778 // If the host is an element container, the native host element is guaranteed to be a
779 // comment and we can reuse that comment as anchor element for the new LContainer.
780 // The comment node in question is already part of the DOM structure so we don't need to append
781 // it again.
782 if (hostTNode.type & TNodeType.ElementContainer) {
783 commentNode = unwrapRNode(slotValue) as RComment;
784 } else {
785 commentNode = insertAnchorNode(hostLView, hostTNode);
786 }
787 lContainer[NATIVE] = commentNode;
788}
789
790/**
791 * Hydration logic that looks up all dehydrated views in this container

Callers 1

locateOrCreateAnchorNodeFunction · 0.70

Calls 2

unwrapRNodeFunction · 0.90
insertAnchorNodeFunction · 0.85

Tested by

no test coverage detected