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

Function shouldAttachRegularTrigger

packages/core/src/defer/triggering.ts:634–657  ·  view source on GitHub ↗

* Defines whether a regular trigger logic (e.g. "on viewport") should be attached * to a defer block. This function defines a condition, which mutually excludes * `deferOn*` and `deferHydrateOn*` triggers, to make sure only one of the trigger * types is active for a block with the current state.

(lView: LView, tNode: TNode)

Source from the content-addressed store, hash-verified

632 * types is active for a block with the current state.
633 */
634function shouldAttachRegularTrigger(lView: LView, tNode: TNode): boolean {
635 const injector = lView[INJECTOR];
636
637 const tDetails = getTDeferBlockDetails(lView[TVIEW], tNode);
638 const incrementalHydrationEnabled = isIncrementalHydrationEnabled(injector);
639 const _hasHydrateTriggers = hasHydrateTriggers(tDetails.flags);
640
641 // On the server:
642 if (typeof ngServerMode !== 'undefined' && ngServerMode) {
643 // Regular triggers are activated on the server when:
644 // - Either Incremental Hydration is *not* enabled
645 // - Or Incremental Hydration is enabled, but a given block doesn't have "hydrate" triggers
646 return !incrementalHydrationEnabled || !_hasHydrateTriggers;
647 }
648
649 // On the client:
650 const lDetails = getLDeferBlockDetails(lView, tNode);
651 const wasServerSideRendered = lDetails[SSR_UNIQUE_ID] !== null;
652
653 if (_hasHydrateTriggers && wasServerSideRendered && incrementalHydrationEnabled) {
654 return false;
655 }
656 return true;
657}
658
659/**
660 * Retrives a Defer Block's list of hydration triggers

Callers 1

shouldAttachTriggerFunction · 0.85

Calls 4

getTDeferBlockDetailsFunction · 0.90
getLDeferBlockDetailsFunction · 0.90
hasHydrateTriggersFunction · 0.85

Tested by

no test coverage detected