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

Function createAnchorNode

packages/core/src/linker/view_container_ref.ts:745–765  ·  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

743 * assigned to the `lContainer[NATIVE]` slot.
744 */
745function createAnchorNode(
746 lContainer: LContainer,
747 hostLView: LView,
748 hostTNode: TNode,
749 slotValue: any,
750) {
751 // We already have a native element (anchor) set, return.
752 if (lContainer[NATIVE]) return;
753
754 let commentNode: RComment;
755 // If the host is an element container, the native host element is guaranteed to be a
756 // comment and we can reuse that comment as anchor element for the new LContainer.
757 // The comment node in question is already part of the DOM structure so we don't need to append
758 // it again.
759 if (hostTNode.type & TNodeType.ElementContainer) {
760 commentNode = unwrapRNode(slotValue) as RComment;
761 } else {
762 commentNode = insertAnchorNode(hostLView, hostTNode);
763 }
764 lContainer[NATIVE] = commentNode;
765}
766
767/**
768 * 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