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

Function appendI18nNodeToCollection

packages/core/src/hydration/i18n.ts:358–380  ·  view source on GitHub ↗

* Marks the current RNode as the hydration root for the given * AST node.

(
  context: I18nHydrationContext,
  state: I18nHydrationState,
  astNode: I18nNode,
)

Source from the content-addressed store, hash-verified

356 * AST node.
357 */
358function appendI18nNodeToCollection(
359 context: I18nHydrationContext,
360 state: I18nHydrationState,
361 astNode: I18nNode,
362) {
363 const noOffsetIndex = astNode.index - HEADER_OFFSET;
364 const {disconnectedNodes} = context;
365 const currentNode = state.currentNode;
366
367 if (state.isConnected) {
368 context.i18nNodes.set(noOffsetIndex, currentNode);
369
370 // We expect the node to be connected, so ensure that it
371 // is not in the set, regardless of whether we found it,
372 // so that the downstream error handling can provide the
373 // proper context.
374 disconnectedNodes.delete(noOffsetIndex);
375 } else {
376 disconnectedNodes.add(noOffsetIndex);
377 }
378
379 return currentNode;
380}
381
382/**
383 * Skip over some sibling nodes during hydration.

Callers 1

collectI18nNodesFromDomFunction · 0.85

Calls 3

setMethod · 0.65
addMethod · 0.65
deleteMethod · 0.45

Tested by

no test coverage detected