* Annotates component host element for hydration: * - by either adding the `ngh` attribute and collecting hydration-related info * for the serialization and transferring to the client * - or by adding the `ngSkipHydration` attribute in case Angular detects that * component contents is not co
( element: RElement, lView: LView, parentDeferBlockId: string | null, context: HydrationContext, )
| 818 | * or `null` when a given component can not be serialized. |
| 819 | */ |
| 820 | function annotateHostElementForHydration( |
| 821 | element: RElement, |
| 822 | lView: LView, |
| 823 | parentDeferBlockId: string | null, |
| 824 | context: HydrationContext, |
| 825 | ): number | null { |
| 826 | const renderer = lView[RENDERER]; |
| 827 | if ( |
| 828 | (hasI18n(lView) && !isI18nHydrationSupportEnabled()) || |
| 829 | componentUsesShadowDomEncapsulation(lView) |
| 830 | ) { |
| 831 | // Attach the skip hydration attribute if this component: |
| 832 | // - either has i18n blocks, since hydrating such blocks is not yet supported |
| 833 | // - or uses ShadowDom view encapsulation, since Domino doesn't support |
| 834 | // shadow DOM, so we can not guarantee that client and server representations |
| 835 | // would exactly match |
| 836 | renderer.setAttribute(element, SKIP_HYDRATION_ATTR_NAME, ''); |
| 837 | return null; |
| 838 | } else { |
| 839 | const ngh = serializeLView(lView, parentDeferBlockId, context); |
| 840 | const index = context.serializedViewCollection.add(ngh); |
| 841 | renderer.setAttribute(element, NGH_ATTR_NAME, index.toString()); |
| 842 | return index; |
| 843 | } |
| 844 | } |
| 845 | |
| 846 | /** |
| 847 | * Annotates defer block comment node for hydration: |
no test coverage detected
searching dependent graphs…