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

Function conditionallyAnnotateNodePath

packages/core/src/hydration/annotate.ts:757–790  ·  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

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