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

Function findHydrationRoot

packages/core/src/hydration/i18n.ts:432–450  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

430 assertDefined(tI18n, 'Expected i18n data to be present in a given TView slot during hydration');
431
432 function findHydrationRoot() {
433 if (isRootTemplateMessage(subTemplateIndex)) {
434 // This is the root of an i18n block. In this case, our hydration root will
435 // depend on where our parent TNode (i.e. the block with i18n applied) is
436 // in the DOM.
437 ngDevMode && assertDefined(parentTNode, 'Expected parent TNode while hydrating i18n root');
438 const rootNode = locateNextRNode(hydrationInfo!, tView, lView, parentTNode!) as Node;
439
440 // If this i18n block is attached to an <ng-container>, then we want to begin
441 // hydrating directly with the RNode. Otherwise, for a TNode with a physical DOM
442 // element, we want to recurse into the first child and begin there.
443 return parentTNode!.type & TNodeType.ElementContainer ? rootNode : getFirstChild(rootNode);
444 }
445
446 // This is a nested template in an i18n block. In this case, the entire view
447 // is translated, and part of a dehydrated view in a container. This means that
448 // we can simply begin hydration with the first dehydrated child.
449 return hydrationInfo?.firstChild as Node;
450 }
451
452 const currentNode = findHydrationRoot();
453 ngDevMode && assertDefined(currentNode, 'Expected root i18n node during hydration');

Callers 1

Calls 4

isRootTemplateMessageFunction · 0.90
assertDefinedFunction · 0.90
locateNextRNodeFunction · 0.90
getFirstChildFunction · 0.90

Tested by

no test coverage detected