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

Function markRNodeAsHavingHydrationMismatch

packages/core/src/hydration/utils.ts:364–390  ·  view source on GitHub ↗
(
  node: RNode,
  expectedNodeDetails: string | null = null,
  actualNodeDetails: string | null = null,
)

Source from the content-addressed store, hash-verified

362}
363
364export function markRNodeAsHavingHydrationMismatch(
365 node: RNode,
366 expectedNodeDetails: string | null = null,
367 actualNodeDetails: string | null = null,
368) {
369 if (!ngDevMode) {
370 throw new Error(
371 'Calling `markRNodeAsMismatchedByHydration` in prod mode ' +
372 'is not supported and likely a mistake.',
373 );
374 }
375
376 // The RNode can be a standard HTMLElement (not an Angular component or directive)
377 // The devtools component tree only displays Angular components & directives
378 // Therefore we attach the debug info to the closest component/directive
379 while (node && !getComponent(node as Element)) {
380 node = node?.parentNode as RNode;
381 }
382
383 if (node) {
384 patchHydrationInfo(node, {
385 status: HydrationStatus.Mismatched,
386 expectedNodeDetails,
387 actualNodeDetails,
388 });
389 }
390}
391
392export function isRNodeClaimedForHydration(node: RNode): boolean {
393 return readHydrationInfo(node)?.status === HydrationStatus.Hydrated;

Callers 4

validateMatchingNodeFunction · 0.90
validateNodeExistsFunction · 0.90
nodeNotFoundAtPathErrorFunction · 0.90

Calls 2

getComponentFunction · 0.90
patchHydrationInfoFunction · 0.85

Tested by

no test coverage detected