@@ -142,7 +142,7 @@ export class FocusMonitor implements OnDestroy {
142142 } ;
143143
144144 /** Used to reference correct document/window */
145- protected _document ? = inject ( DOCUMENT , { optional : true } ) ;
145+ protected _document = inject ( DOCUMENT ) ;
146146
147147 /** Subject for stopping our InputModalityDetector subscription. */
148148 private readonly _stopInputModalityDetector = new Subject < void > ( ) ;
@@ -206,7 +206,7 @@ export class FocusMonitor implements OnDestroy {
206206 // If the element is inside the shadow DOM, we need to bind our focus/blur listeners to
207207 // the shadow root, rather than the `document`, because the browser won't emit focus events
208208 // to the `document`, if focus is moving within the same shadow root.
209- const rootNode = _getShadowRoot ( nativeElement ) || this . _getDocument ( ) ;
209+ const rootNode = _getShadowRoot ( nativeElement ) || this . _document ;
210210 const cachedInfo = this . _elementInfo . get ( nativeElement ) ;
211211
212212 // Check if we're already monitoring this element.
@@ -280,7 +280,7 @@ export class FocusMonitor implements OnDestroy {
280280 options ?: FocusOptions ,
281281 ) : void {
282282 const nativeElement = coerceElement ( element ) ;
283- const focusedElement = this . _getDocument ( ) . activeElement ;
283+ const focusedElement = this . _document . activeElement ;
284284
285285 // If the element is focused already, calling `focus` again won't trigger the event listener
286286 // which means that the focus classes won't be updated. If that's the case, update the classes
@@ -303,15 +303,9 @@ export class FocusMonitor implements OnDestroy {
303303 this . _elementInfo . forEach ( ( _info , element ) => this . stopMonitoring ( element ) ) ;
304304 }
305305
306- /** Access injected document if available or fallback to global document reference */
307- private _getDocument ( ) : Document {
308- return this . _document || document ;
309- }
310-
311306 /** Use defaultView of injected document if available or fallback to global window reference */
312307 private _getWindow ( ) : Window {
313- const doc = this . _getDocument ( ) ;
314- return doc . defaultView || window ;
308+ return this . _document . defaultView || window ;
315309 }
316310
317311 private _getFocusOrigin ( focusEventTarget : HTMLElement | null ) : FocusOrigin {
0 commit comments