@@ -29,12 +29,21 @@ import {performanceMarkFeature} from '../util/performance';
2929import { NgZone } from '../zone' ;
3030import { withEventReplay } from './event_replay' ;
3131
32+ import {
33+ ChangeDetectionScheduler ,
34+ NotificationSource ,
35+ } from '../change_detection/scheduling/zoneless_scheduling' ;
36+ import { DEHYDRATED_BLOCK_REGISTRY , DehydratedBlockRegistry } from '../defer/registry' ;
37+ import { processAndInitTriggers } from '../defer/triggering' ;
38+ import { DOCUMENT } from '../document' ;
39+ import { DOC_PAGE_BASE_URL } from '../error_details_base_url' ;
3240import { cleanupDehydratedViews } from './cleanup' ;
3341import {
3442 enableClaimDehydratedIcuCaseImpl ,
3543 enablePrepareI18nBlockForHydrationImpl ,
3644 setIsI18nHydrationSupportEnabled ,
3745} from './i18n' ;
46+ import { gatherDeferBlocksCommentNodes } from './node_lookup_utils' ;
3847import {
3948 IS_HYDRATION_DOM_REUSE_ENABLED ,
4049 IS_I18N_HYDRATION_ENABLED ,
@@ -52,11 +61,6 @@ import {
5261 verifySsrContentsIntegrity ,
5362} from './utils' ;
5463import { enableFindMatchingDehydratedViewImpl } from './views' ;
55- import { DEHYDRATED_BLOCK_REGISTRY , DehydratedBlockRegistry } from '../defer/registry' ;
56- import { gatherDeferBlocksCommentNodes } from './node_lookup_utils' ;
57- import { processAndInitTriggers } from '../defer/triggering' ;
58- import { DOCUMENT } from '../document' ;
59- import { DOC_PAGE_BASE_URL } from '../error_details_base_url' ;
6064
6165/**
6266 * Indicates whether the hydration-related code was added,
@@ -277,6 +281,7 @@ export function withDomHydration(): EnvironmentProviders {
277281 {
278282 provide : APP_BOOTSTRAP_LISTENER ,
279283 useFactory : ( ) => {
284+ const scheduler = inject ( ChangeDetectionScheduler ) ;
280285 if ( inject ( IS_HYDRATION_DOM_REUSE_ENABLED ) ) {
281286 const appRef = inject ( ApplicationRef ) ;
282287
@@ -304,6 +309,8 @@ export function withDomHydration(): EnvironmentProviders {
304309 countBlocksSkippedByHydration ( appRef . injector ) ;
305310 printHydrationStats ( appRef . injector ) ;
306311 }
312+ // We need to schedule the execution of the render hooks because the hydration cleanup alters the DOM.
313+ scheduler . notify ( NotificationSource . RenderHook ) ;
307314 } ) ;
308315 } ;
309316 }
0 commit comments