Skip to content

Commit 7f278ad

Browse files
jelbourntinayuangao
authored andcommitted
Revert "refactor: avoid casting document to any in constructor (#10775)" (#10824)
This reverts commit e60f5fc.
1 parent f1a33e9 commit 7f278ad

File tree

18 files changed

+57
-30
lines changed

18 files changed

+57
-30
lines changed

src/cdk-experimental/dialog/dialog-container.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export class CdkDialogContainer extends BasePortalOutlet {
109109
private _elementRef: ElementRef,
110110
private _focusTrapFactory: FocusTrapFactory,
111111
private _changeDetectorRef: ChangeDetectorRef,
112-
@Optional() @Inject(DOCUMENT) private _document: Document) {
112+
@Optional() @Inject(DOCUMENT) private _document: any) {
113113
super();
114114
}
115115

src/cdk/a11y/aria-describer/aria-describer.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ let messagesContainer: HTMLElement | null = null;
5555
*/
5656
@Injectable({providedIn: 'root'})
5757
export class AriaDescriber {
58-
constructor(@Inject(DOCUMENT) private _document: Document) {}
58+
private _document: Document;
59+
60+
constructor(@Inject(DOCUMENT) _document: any) {
61+
this._document = _document;
62+
}
5963

6064
/**
6165
* Adds to the host element an aria-describedby reference to a hidden element that contains
@@ -209,8 +213,7 @@ export class AriaDescriber {
209213

210214

211215
/** @docs-private @deprecated @deletion-target 7.0.0 */
212-
export function ARIA_DESCRIBER_PROVIDER_FACTORY(parentDispatcher: AriaDescriber,
213-
_document: Document) {
216+
export function ARIA_DESCRIBER_PROVIDER_FACTORY(parentDispatcher: AriaDescriber, _document: any) {
214217
return parentDispatcher || new AriaDescriber(_document);
215218
}
216219

@@ -220,7 +223,7 @@ export const ARIA_DESCRIBER_PROVIDER = {
220223
provide: AriaDescriber,
221224
deps: [
222225
[new Optional(), new SkipSelf(), AriaDescriber],
223-
DOCUMENT as InjectionToken<Document>
226+
DOCUMENT as InjectionToken<any>
224227
],
225228
useFactory: ARIA_DESCRIBER_PROVIDER_FACTORY
226229
};

src/cdk/a11y/focus-trap/focus-trap.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,15 @@ export class FocusTrap {
285285
/** Factory that allows easy instantiation of focus traps. */
286286
@Injectable({providedIn: 'root'})
287287
export class FocusTrapFactory {
288+
private _document: Document;
289+
288290
constructor(
289291
private _checker: InteractivityChecker,
290292
private _ngZone: NgZone,
291-
@Inject(DOCUMENT) private _document: Document) {}
293+
@Inject(DOCUMENT) _document: any) {
294+
295+
this._document = _document;
296+
}
292297

293298
/**
294299
* Creates a focus-trapped region around the given element.
@@ -309,6 +314,8 @@ export class FocusTrapFactory {
309314
exportAs: 'cdkTrapFocus',
310315
})
311316
export class CdkTrapFocus implements OnDestroy, AfterContentInit {
317+
private _document: Document;
318+
312319
/** Underlying FocusTrap instance. */
313320
focusTrap: FocusTrap;
314321

@@ -332,7 +339,7 @@ export class CdkTrapFocus implements OnDestroy, AfterContentInit {
332339
constructor(
333340
private _elementRef: ElementRef,
334341
private _focusTrapFactory: FocusTrapFactory,
335-
@Inject(DOCUMENT) private _document: Document) {
342+
@Inject(DOCUMENT) _document: any) {
336343

337344
this._document = _document;
338345
this.focusTrap = this._focusTrapFactory.create(this._elementRef.nativeElement, true);

src/cdk/a11y/live-announcer/live-announcer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class LiveAnnouncer implements OnDestroy {
2727

2828
constructor(
2929
@Optional() @Inject(LIVE_ANNOUNCER_ELEMENT_TOKEN) elementToken: any,
30-
@Inject(DOCUMENT) private _document: Document) {
30+
@Inject(DOCUMENT) private _document: any) {
3131

3232
// We inject the live element as `any` because the constructor signature cannot reference
3333
// browser globals (HTMLElement) on non-browser environments, since having a class decorator
@@ -83,7 +83,7 @@ export class LiveAnnouncer implements OnDestroy {
8383

8484
/** @docs-private @deprecated @deletion-target 7.0.0 */
8585
export function LIVE_ANNOUNCER_PROVIDER_FACTORY(
86-
parentDispatcher: LiveAnnouncer, liveElement: any, _document: Document) {
86+
parentDispatcher: LiveAnnouncer, liveElement: any, _document: any) {
8787
return parentDispatcher || new LiveAnnouncer(liveElement, _document);
8888
}
8989

src/cdk/overlay/keyboard/overlay-keyboard-dispatcher.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ export class OverlayKeyboardDispatcher implements OnDestroy {
2929
/** Currently attached overlays in the order they were attached. */
3030
_attachedOverlays: OverlayRef[] = [];
3131

32+
private _document: Document;
3233
private _isAttached: boolean;
3334

34-
constructor(@Inject(DOCUMENT) private _document: Document) {}
35+
constructor(@Inject(DOCUMENT) document: any) {
36+
this._document = document;
37+
}
3538

3639
ngOnDestroy() {
3740
this._detach();
@@ -94,7 +97,7 @@ export class OverlayKeyboardDispatcher implements OnDestroy {
9497

9598
/** @docs-private @deprecated @deletion-target 7.0.0 */
9699
export function OVERLAY_KEYBOARD_DISPATCHER_PROVIDER_FACTORY(
97-
dispatcher: OverlayKeyboardDispatcher, _document: Document) {
100+
dispatcher: OverlayKeyboardDispatcher, _document: any) {
98101
return dispatcher || new OverlayKeyboardDispatcher(_document);
99102
}
100103

@@ -108,7 +111,7 @@ export const OVERLAY_KEYBOARD_DISPATCHER_PROVIDER = {
108111

109112
// Coerce to `InjectionToken` so that the `deps` match the "shape"
110113
// of the type expected by Angular
111-
DOCUMENT as InjectionToken<Document>
114+
DOCUMENT as InjectionToken<any>
112115
],
113116
useFactory: OVERLAY_KEYBOARD_DISPATCHER_PROVIDER_FACTORY
114117
};

src/cdk/overlay/overlay-container.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
export class OverlayContainer implements OnDestroy {
2323
protected _containerElement: HTMLElement;
2424

25-
constructor(@Inject(DOCUMENT) private _document: Document) {}
25+
constructor(@Inject(DOCUMENT) private _document: any) {}
2626

2727
ngOnDestroy() {
2828
if (this._containerElement && this._containerElement.parentNode) {
@@ -57,7 +57,7 @@ export class OverlayContainer implements OnDestroy {
5757

5858
/** @docs-private @deprecated @deletion-target 7.0.0 */
5959
export function OVERLAY_CONTAINER_PROVIDER_FACTORY(parentContainer: OverlayContainer,
60-
_document: Document) {
60+
_document: any) {
6161
return parentContainer || new OverlayContainer(_document);
6262
}
6363

@@ -67,8 +67,7 @@ export const OVERLAY_CONTAINER_PROVIDER = {
6767
provide: OverlayContainer,
6868
deps: [
6969
[new Optional(), new SkipSelf(), OverlayContainer],
70-
// We need to use the InjectionToken somewhere to keep TS happy
71-
DOCUMENT as InjectionToken<Document>
70+
DOCUMENT as InjectionToken<any> // We need to use the InjectionToken somewhere to keep TS happy
7271
],
7372
useFactory: OVERLAY_CONTAINER_PROVIDER_FACTORY
7473
};

src/cdk/overlay/overlay.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class Overlay {
5151
private _appRef: ApplicationRef,
5252
private _injector: Injector,
5353
private _ngZone: NgZone,
54-
@Inject(DOCUMENT) private _document: Document,
54+
@Inject(DOCUMENT) private _document: any,
5555
private _directionality: Directionality) { }
5656

5757
/**

src/cdk/overlay/position/overlay-position-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {GlobalPositionStrategy} from './global-position-strategy';
2020
export class OverlayPositionBuilder {
2121
constructor(
2222
private _viewportRuler: ViewportRuler,
23-
@Inject(DOCUMENT) private _document: Document) { }
23+
@Inject(DOCUMENT) private _document: any) { }
2424

2525
/**
2626
* Creates a global position strategy.

src/cdk/overlay/scroll/block-scroll-strategy.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ export class BlockScrollStrategy implements ScrollStrategy {
1717
private _previousHTMLStyles = { top: '', left: '' };
1818
private _previousScrollPosition: { top: number, left: number };
1919
private _isEnabled = false;
20+
private _document: Document;
2021

21-
constructor(private _viewportRuler: ViewportRuler, private _document: Document) {}
22+
constructor(private _viewportRuler: ViewportRuler, document: any) {
23+
this._document = document;
24+
}
2225

2326
/** Attaches this scroll strategy to an overlay. */
2427
attach() { }

src/cdk/overlay/scroll/scroll-strategy-options.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@ import {
2626
*/
2727
@Injectable({providedIn: 'root'})
2828
export class ScrollStrategyOptions {
29+
private _document: Document;
30+
2931
constructor(
3032
private _scrollDispatcher: ScrollDispatcher,
3133
private _viewportRuler: ViewportRuler,
3234
private _ngZone: NgZone,
33-
@Inject(DOCUMENT) private _document: Document) {}
35+
@Inject(DOCUMENT) document: any) {
36+
this._document = document;
37+
}
3438

3539
/** Do nothing on scroll. */
3640
noop = () => new NoopScrollStrategy();

0 commit comments

Comments
 (0)