@@ -24,7 +24,6 @@ import {enableLocateOrCreateElementContainerNodeImpl} from '../render3/instructi
2424import { enableApplyRootElementTransformImpl } from '../render3/instructions/shared' ;
2525import { enableLocateOrCreateContainerAnchorImpl } from '../render3/instructions/template' ;
2626import { enableLocateOrCreateTextNodeImpl } from '../render3/instructions/text' ;
27- import { getDocument } from '../render3/interfaces/document' ;
2827import { TransferState } from '../transfer_state' ;
2928import { performanceMarkFeature } from '../util/performance' ;
3029import { NgZone } from '../zone' ;
@@ -56,6 +55,7 @@ import {enableFindMatchingDehydratedViewImpl} from './views';
5655import { DEHYDRATED_BLOCK_REGISTRY , DehydratedBlockRegistry } from '../defer/registry' ;
5756import { gatherDeferBlocksCommentNodes } from './node_lookup_utils' ;
5857import { processAndInitTriggers } from '../defer/triggering' ;
58+ import { DOCUMENT } from '../document' ;
5959
6060/**
6161 * Indicates whether the hydration-related code was added,
@@ -186,8 +186,7 @@ export const CLIENT_RENDER_MODE_FLAG = 'ngcm';
186186/**
187187 * Checks whether the `RenderMode.Client` was defined for the current route.
188188 */
189- function isClientRenderModeEnabled ( ) : boolean {
190- const doc = getDocument ( ) ;
189+ function isClientRenderModeEnabled ( doc : Document ) : boolean {
191190 return (
192191 ( typeof ngServerMode === 'undefined' || ! ngServerMode ) &&
193192 doc . body . hasAttribute ( CLIENT_RENDER_MODE_FLAG )
@@ -237,10 +236,15 @@ export function withDomHydration(): EnvironmentProviders {
237236 return ;
238237 }
239238
239+ const doc = inject ( DOCUMENT ) ;
240240 if ( inject ( IS_HYDRATION_DOM_REUSE_ENABLED ) ) {
241- verifySsrContentsIntegrity ( getDocument ( ) ) ;
241+ verifySsrContentsIntegrity ( doc ) ;
242242 enableHydrationRuntimeSupport ( ) ;
243- } else if ( typeof ngDevMode !== 'undefined' && ngDevMode && ! isClientRenderModeEnabled ( ) ) {
243+ } else if (
244+ typeof ngDevMode !== 'undefined' &&
245+ ngDevMode &&
246+ ! isClientRenderModeEnabled ( doc )
247+ ) {
244248 const console = inject ( Console ) ;
245249 const message = formatRuntimeError (
246250 RuntimeErrorCode . MISSING_HYDRATION_ANNOTATIONS ,
@@ -369,7 +373,7 @@ export function withIncrementalHydration(): Provider[] {
369373 provide : APP_BOOTSTRAP_LISTENER ,
370374 useFactory : ( ) => {
371375 const injector = inject ( Injector ) ;
372- const doc = getDocument ( ) ;
376+ const doc = inject ( DOCUMENT ) ;
373377
374378 return ( ) => {
375379 const deferBlockData = processBlockData ( injector ) ;
0 commit comments