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

Function conditionallyAnnotateNodePath

packages/core/src/hydration/annotate.ts:762–795  ·  view source on GitHub ↗

* Serializes node location in cases when it's needed, specifically: * * 1. If `tNode.projectionNext` is different from `tNode.next` - it means that * the next `tNode` after projection is different from the one in the original * template. Since hydration relies on `tNode.next`, this seri

(
  ngh: SerializedView,
  tNode: TNode,
  lView: LView<unknown>,
  excludedParentNodes: Set<number> | null,
)

Source from the content-addressed store, hash-verified

760 * connection to identify the location of a node.
761 */
762function conditionallyAnnotateNodePath(
763 ngh: SerializedView,
764 tNode: TNode,
765 lView: LView<unknown>,
766 excludedParentNodes: Set<number> | null,
767) {
768 if (isProjectionTNode(tNode)) {
769 // Do not annotate projection nodes (<ng-content />), since
770 // they don't have a corresponding DOM node representing them.
771 return;
772 }
773
774 // Handle case #1 described above.
775 if (
776 tNode.projectionNext &&
777 tNode.projectionNext !== tNode.next &&
778 !isInSkipHydrationBlock(tNode.projectionNext)
779 ) {
780 appendSerializedNodePath(ngh, tNode.projectionNext, lView, excludedParentNodes);
781 }
782
783 // Handle case #2 described above.
784 // Note: we only do that for the first node (i.e. when `tNode.prev === null`),
785 // the rest of the nodes would rely on the current node location, so no extra
786 // annotation is needed.
787 if (
788 tNode.prev === null &&
789 tNode.parent !== null &&
790 isDisconnectedNode(tNode.parent, lView) &&
791 !isDisconnectedNode(tNode, lView)
792 ) {
793 appendSerializedNodePath(ngh, tNode, lView, excludedParentNodes);
794 }
795}
796
797/**
798 * Determines whether a component instance that is represented

Callers 1

serializeLViewFunction · 0.85

Calls 4

isProjectionTNodeFunction · 0.90
isInSkipHydrationBlockFunction · 0.90
isDisconnectedNodeFunction · 0.90
appendSerializedNodePathFunction · 0.85

Tested by

no test coverage detected