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

Function getFirstNativeNodeForI18nNode

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

* Helper function to get the first native node to begin hydrating * the given i18n node.

(lView: LView, node: I18nNode)

Source from the content-addressed store, hash-verified

294 * the given i18n node.
295 */
296function getFirstNativeNodeForI18nNode(lView: LView, node: I18nNode) {
297 const tView = lView[TVIEW];
298 const maybeTNode = tView.data[node.index];
299
300 if (isTNodeShape(maybeTNode)) {
301 // If the node is backed by an actual TNode, we can simply delegate.
302 return getFirstNativeNode(lView, maybeTNode);
303 } else if (node.kind === I18nNodeKind.ICU) {
304 // A nested ICU container won't have an actual TNode. In that case, we can use
305 // an iterator to find the first child.
306 const icuIterator = createIcuIterator(maybeTNode as TIcu, lView);
307 let rNode: RNode | null = icuIterator();
308
309 // If the ICU container has no nodes, then we use the ICU anchor as the node.
310 return rNode ?? unwrapRNode(lView[node.index]);
311 } else {
312 // Otherwise, the node is a text or trivial element in an ICU container,
313 // and we can just use the RNode directly.
314 return unwrapRNode(lView[node.index]) ?? null;
315 }
316}
317
318/**
319 * Describes shared data available during the hydration process.

Callers 1

serializeI18nNodeFunction · 0.85

Calls 4

isTNodeShapeFunction · 0.90
getFirstNativeNodeFunction · 0.90
createIcuIteratorFunction · 0.90
unwrapRNodeFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…