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

Function getParentBlockHydrationQueue

packages/core/src/hydration/utils.ts:601–632  ·  view source on GitHub ↗
(
  deferBlockId: string,
  injector: Injector,
)

Source from the content-addressed store, hash-verified

599 * Note: This is utilizing serialized information to navigate up the tree
600 */
601export function getParentBlockHydrationQueue(
602 deferBlockId: string,
603 injector: Injector,
604): {parentBlockPromise: Promise<void> | null; hydrationQueue: string[]} {
605 const dehydratedBlockRegistry = injector.get(DEHYDRATED_BLOCK_REGISTRY);
606 const transferState = injector.get(TransferState);
607 const deferBlockParents = transferState.get(NGH_DEFER_BLOCKS_KEY, {});
608
609 let isTopMostDeferBlock = false;
610 let currentBlockId: string | undefined = deferBlockId;
611 let parentBlockPromise: Promise<void> | null = null;
612 const hydrationQueue: string[] = [];
613
614 while (!isTopMostDeferBlock && currentBlockId) {
615 ngDevMode &&
616 assertEqual(
617 hydrationQueue.indexOf(currentBlockId),
618 -1,
619 'Internal error: defer block hierarchy has a cycle.',
620 );
621
622 isTopMostDeferBlock = dehydratedBlockRegistry.has(currentBlockId);
623 const hydratingParentBlock = dehydratedBlockRegistry.hydrating.get(currentBlockId);
624 if (parentBlockPromise === null && hydratingParentBlock != null) {
625 parentBlockPromise = hydratingParentBlock.promise;
626 break;
627 }
628 hydrationQueue.unshift(currentBlockId);
629 currentBlockId = deferBlockParents[currentBlockId][DEFER_PARENT_BLOCK_ID];
630 }
631 return {parentBlockPromise, hydrationQueue};
632}
633
634function gatherDeferBlocksByJSActionAttribute(doc: Document): Set<HTMLElement> {
635 const jsactionNodes = doc.body.querySelectorAll('[jsaction]');

Callers 1

Calls 4

assertEqualFunction · 0.90
indexOfMethod · 0.80
getMethod · 0.65
hasMethod · 0.65

Tested by

no test coverage detected