@@ -142,7 +142,7 @@ export class FocusMonitor implements OnDestroy {
142
142
} ;
143
143
144
144
/** Used to reference correct document/window */
145
- protected _document ? = inject ( DOCUMENT , { optional : true } ) ;
145
+ protected _document = inject ( DOCUMENT ) ;
146
146
147
147
/** Subject for stopping our InputModalityDetector subscription. */
148
148
private readonly _stopInputModalityDetector = new Subject < void > ( ) ;
@@ -206,7 +206,7 @@ export class FocusMonitor implements OnDestroy {
206
206
// If the element is inside the shadow DOM, we need to bind our focus/blur listeners to
207
207
// the shadow root, rather than the `document`, because the browser won't emit focus events
208
208
// 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 ;
210
210
const cachedInfo = this . _elementInfo . get ( nativeElement ) ;
211
211
212
212
// Check if we're already monitoring this element.
@@ -280,7 +280,7 @@ export class FocusMonitor implements OnDestroy {
280
280
options ?: FocusOptions ,
281
281
) : void {
282
282
const nativeElement = coerceElement ( element ) ;
283
- const focusedElement = this . _getDocument ( ) . activeElement ;
283
+ const focusedElement = this . _document . activeElement ;
284
284
285
285
// If the element is focused already, calling `focus` again won't trigger the event listener
286
286
// 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 {
303
303
this . _elementInfo . forEach ( ( _info , element ) => this . stopMonitoring ( element ) ) ;
304
304
}
305
305
306
- /** Access injected document if available or fallback to global document reference */
307
- private _getDocument ( ) : Document {
308
- return this . _document || document ;
309
- }
310
-
311
306
/** Use defaultView of injected document if available or fallback to global window reference */
312
307
private _getWindow ( ) : Window {
313
- const doc = this . _getDocument ( ) ;
314
- return doc . defaultView || window ;
308
+ return this . _document . defaultView || window ;
315
309
}
316
310
317
311
private _getFocusOrigin ( focusEventTarget : HTMLElement | null ) : FocusOrigin {
0 commit comments