* 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)
| 613 | * types is active for a block with the current state. |
| 614 | */ |
| 615 | function shouldAttachRegularTrigger(lView: LView, tNode: TNode): boolean { |
| 616 | const injector = lView[INJECTOR]; |
| 617 | |
| 618 | const tDetails = getTDeferBlockDetails(lView[TVIEW], tNode); |
| 619 | const incrementalHydrationEnabled = isIncrementalHydrationEnabled(injector); |
| 620 | const _hasHydrateTriggers = hasHydrateTriggers(tDetails.flags); |
| 621 | |
| 622 | // On the server: |
| 623 | if (typeof ngServerMode !== 'undefined' && ngServerMode) { |
| 624 | // Regular triggers are activated on the server when: |
| 625 | // - Either Incremental Hydration is *not* enabled |
| 626 | // - Or Incremental Hydration is enabled, but a given block doesn't have "hydrate" triggers |
| 627 | return !incrementalHydrationEnabled || !_hasHydrateTriggers; |
| 628 | } |
| 629 | |
| 630 | // On the client: |
| 631 | const lDetails = getLDeferBlockDetails(lView, tNode); |
| 632 | const wasServerSideRendered = lDetails[SSR_UNIQUE_ID] !== null; |
| 633 | |
| 634 | if (_hasHydrateTriggers && wasServerSideRendered && incrementalHydrationEnabled) { |
| 635 | return false; |
| 636 | } |
| 637 | return true; |
| 638 | } |
| 639 | |
| 640 | /** |
| 641 | * Retrives a Defer Block's list of hydration triggers |
no test coverage detected
searching dependent graphs…