MCPcopy Index your code
hub / github.com/angular/angular / validateNodeExists

Function validateNodeExists

packages/core/src/hydration/error_handling.ts:143–166  ·  view source on GitHub ↗
(
  node: RNode | null,
  lView: LView | null = null,
  tNode: TNode | null = null,
)

Source from the content-addressed store, hash-verified

141 * Validates that a node exists or throws
142 */
143export function validateNodeExists(
144 node: RNode | null,
145 lView: LView | null = null,
146 tNode: TNode | null = null,
147): void {
148 if (!node) {
149 const header =
150 'During hydration, Angular expected an element to be present at this location.\n\n';
151 let expected = '';
152 let footer = '';
153 if (lView !== null && tNode !== null) {
154 expected = describeExpectedDom(lView, tNode, false);
155 footer = getHydrationErrorFooter();
156
157 // Since the node is missing, we use the closest node to attach the error to
158 markRNodeAsHavingHydrationMismatch(unwrapRNode(lView[HOST]!), expected, '');
159 }
160
161 throw new RuntimeError(
162 RuntimeErrorCode.HYDRATION_MISSING_NODE,
163 `${header}${expected}\n\n${footer}`,
164 );
165 }
166}
167
168/**
169 * Builds the hydration error message when a node is not found

Calls 4

unwrapRNodeFunction · 0.90
describeExpectedDomFunction · 0.85
getHydrationErrorFooterFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…