Skip to content

Revert "refactor: avoid casting document to any in constructor (#10775)" #10824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cdk-experimental/dialog/dialog-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class CdkDialogContainer extends BasePortalOutlet {
private _elementRef: ElementRef,
private _focusTrapFactory: FocusTrapFactory,
private _changeDetectorRef: ChangeDetectorRef,
@Optional() @Inject(DOCUMENT) private _document: Document) {
@Optional() @Inject(DOCUMENT) private _document: any) {
super();
}

Expand Down
11 changes: 7 additions & 4 deletions src/cdk/a11y/aria-describer/aria-describer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ let messagesContainer: HTMLElement | null = null;
*/
@Injectable({providedIn: 'root'})
export class AriaDescriber {
constructor(@Inject(DOCUMENT) private _document: Document) {}
private _document: Document;

constructor(@Inject(DOCUMENT) _document: any) {
this._document = _document;
}

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


/** @docs-private @deprecated @deletion-target 7.0.0 */
export function ARIA_DESCRIBER_PROVIDER_FACTORY(parentDispatcher: AriaDescriber,
_document: Document) {
export function ARIA_DESCRIBER_PROVIDER_FACTORY(parentDispatcher: AriaDescriber, _document: any) {
return parentDispatcher || new AriaDescriber(_document);
}

Expand All @@ -220,7 +223,7 @@ export const ARIA_DESCRIBER_PROVIDER = {
provide: AriaDescriber,
deps: [
[new Optional(), new SkipSelf(), AriaDescriber],
DOCUMENT as InjectionToken<Document>
DOCUMENT as InjectionToken<any>
],
useFactory: ARIA_DESCRIBER_PROVIDER_FACTORY
};
11 changes: 9 additions & 2 deletions src/cdk/a11y/focus-trap/focus-trap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,15 @@ export class FocusTrap {
/** Factory that allows easy instantiation of focus traps. */
@Injectable({providedIn: 'root'})
export class FocusTrapFactory {
private _document: Document;

constructor(
private _checker: InteractivityChecker,
private _ngZone: NgZone,
@Inject(DOCUMENT) private _document: Document) {}
@Inject(DOCUMENT) _document: any) {

this._document = _document;
}

/**
* Creates a focus-trapped region around the given element.
Expand All @@ -309,6 +314,8 @@ export class FocusTrapFactory {
exportAs: 'cdkTrapFocus',
})
export class CdkTrapFocus implements OnDestroy, AfterContentInit {
private _document: Document;

/** Underlying FocusTrap instance. */
focusTrap: FocusTrap;

Expand All @@ -332,7 +339,7 @@ export class CdkTrapFocus implements OnDestroy, AfterContentInit {
constructor(
private _elementRef: ElementRef,
private _focusTrapFactory: FocusTrapFactory,
@Inject(DOCUMENT) private _document: Document) {
@Inject(DOCUMENT) _document: any) {

this._document = _document;
this.focusTrap = this._focusTrapFactory.create(this._elementRef.nativeElement, true);
Expand Down
4 changes: 2 additions & 2 deletions src/cdk/a11y/live-announcer/live-announcer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class LiveAnnouncer implements OnDestroy {

constructor(
@Optional() @Inject(LIVE_ANNOUNCER_ELEMENT_TOKEN) elementToken: any,
@Inject(DOCUMENT) private _document: Document) {
@Inject(DOCUMENT) private _document: any) {

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

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

Expand Down
9 changes: 6 additions & 3 deletions src/cdk/overlay/keyboard/overlay-keyboard-dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ export class OverlayKeyboardDispatcher implements OnDestroy {
/** Currently attached overlays in the order they were attached. */
_attachedOverlays: OverlayRef[] = [];

private _document: Document;
private _isAttached: boolean;

constructor(@Inject(DOCUMENT) private _document: Document) {}
constructor(@Inject(DOCUMENT) document: any) {
this._document = document;
}

ngOnDestroy() {
this._detach();
Expand Down Expand Up @@ -94,7 +97,7 @@ export class OverlayKeyboardDispatcher implements OnDestroy {

/** @docs-private @deprecated @deletion-target 7.0.0 */
export function OVERLAY_KEYBOARD_DISPATCHER_PROVIDER_FACTORY(
dispatcher: OverlayKeyboardDispatcher, _document: Document) {
dispatcher: OverlayKeyboardDispatcher, _document: any) {
return dispatcher || new OverlayKeyboardDispatcher(_document);
}

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

// Coerce to `InjectionToken` so that the `deps` match the "shape"
// of the type expected by Angular
DOCUMENT as InjectionToken<Document>
DOCUMENT as InjectionToken<any>
],
useFactory: OVERLAY_KEYBOARD_DISPATCHER_PROVIDER_FACTORY
};
7 changes: 3 additions & 4 deletions src/cdk/overlay/overlay-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
export class OverlayContainer implements OnDestroy {
protected _containerElement: HTMLElement;

constructor(@Inject(DOCUMENT) private _document: Document) {}
constructor(@Inject(DOCUMENT) private _document: any) {}

ngOnDestroy() {
if (this._containerElement && this._containerElement.parentNode) {
Expand Down Expand Up @@ -57,7 +57,7 @@ export class OverlayContainer implements OnDestroy {

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

Expand All @@ -67,8 +67,7 @@ export const OVERLAY_CONTAINER_PROVIDER = {
provide: OverlayContainer,
deps: [
[new Optional(), new SkipSelf(), OverlayContainer],
// We need to use the InjectionToken somewhere to keep TS happy
DOCUMENT as InjectionToken<Document>
DOCUMENT as InjectionToken<any> // We need to use the InjectionToken somewhere to keep TS happy
],
useFactory: OVERLAY_CONTAINER_PROVIDER_FACTORY
};
2 changes: 1 addition & 1 deletion src/cdk/overlay/overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class Overlay {
private _appRef: ApplicationRef,
private _injector: Injector,
private _ngZone: NgZone,
@Inject(DOCUMENT) private _document: Document,
@Inject(DOCUMENT) private _document: any,
private _directionality: Directionality) { }

/**
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/overlay/position/overlay-position-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {GlobalPositionStrategy} from './global-position-strategy';
export class OverlayPositionBuilder {
constructor(
private _viewportRuler: ViewportRuler,
@Inject(DOCUMENT) private _document: Document) { }
@Inject(DOCUMENT) private _document: any) { }

/**
* Creates a global position strategy.
Expand Down
5 changes: 4 additions & 1 deletion src/cdk/overlay/scroll/block-scroll-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ export class BlockScrollStrategy implements ScrollStrategy {
private _previousHTMLStyles = { top: '', left: '' };
private _previousScrollPosition: { top: number, left: number };
private _isEnabled = false;
private _document: Document;

constructor(private _viewportRuler: ViewportRuler, private _document: Document) {}
constructor(private _viewportRuler: ViewportRuler, document: any) {
this._document = document;
}

/** Attaches this scroll strategy to an overlay. */
attach() { }
Expand Down
6 changes: 5 additions & 1 deletion src/cdk/overlay/scroll/scroll-strategy-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ import {
*/
@Injectable({providedIn: 'root'})
export class ScrollStrategyOptions {
private _document: Document;

constructor(
private _scrollDispatcher: ScrollDispatcher,
private _viewportRuler: ViewportRuler,
private _ngZone: NgZone,
@Inject(DOCUMENT) private _document: Document) {}
@Inject(DOCUMENT) document: any) {
this._document = document;
}

/** Do nothing on scroll. */
noop = () => new NoopScrollStrategy();
Expand Down
2 changes: 1 addition & 1 deletion src/lib/autocomplete/autocomplete-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class MatAutocompleteTrigger implements ControlValueAccessor, OnDestroy {
@Inject(MAT_AUTOCOMPLETE_SCROLL_STRATEGY) private _scrollStrategy,
@Optional() private _dir: Directionality,
@Optional() @Host() private _formField: MatFormField,
@Optional() @Inject(DOCUMENT) private _document: Document,
@Optional() @Inject(DOCUMENT) private _document: any,
// @deletion-target 7.0.0 Make `_viewportRuler` required.
private _viewportRuler?: ViewportRuler) {}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/badge/badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class MatBadge implements OnDestroy {
private _badgeElement: HTMLElement;

constructor(
@Optional() @Inject(DOCUMENT) private _document: Document,
@Optional() @Inject(DOCUMENT) private _document: any,
private _ngZone: NgZone,
private _elementRef: ElementRef,
private _ariaDescriber: AriaDescriber) {}
Expand Down
6 changes: 5 additions & 1 deletion src/lib/bottom-sheet/bottom-sheet-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ export class MatBottomSheetContainer extends BasePortalOutlet implements OnDestr
/** Element that was focused before the bottom sheet was opened. */
private _elementFocusedBeforeOpened: HTMLElement | null = null;

/** Server-side rendering-compatible reference to the global document object. */
private _document: Document;

/** Whether the component has been destroyed. */
private _destroyed: boolean;

Expand All @@ -87,9 +90,10 @@ export class MatBottomSheetContainer extends BasePortalOutlet implements OnDestr
private _changeDetectorRef: ChangeDetectorRef,
private _focusTrapFactory: FocusTrapFactory,
breakpointObserver: BreakpointObserver,
@Optional() @Inject(DOCUMENT) private _document: Document) {
@Optional() @Inject(DOCUMENT) document: any) {
super();

this._document = document;
this._breakpointSubscription = breakpointObserver
.observe([Breakpoints.Medium, Breakpoints.Large, Breakpoints.XLarge])
.subscribe(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/datepicker/datepicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ export class MatDatepicker<D> implements OnDestroy, CanColor {
@Inject(MAT_DATEPICKER_SCROLL_STRATEGY) private _scrollStrategy,
@Optional() private _dateAdapter: DateAdapter<D>,
@Optional() private _dir: Directionality,
@Optional() @Inject(DOCUMENT) private _document: Document) {
@Optional() @Inject(DOCUMENT) private _document: any) {
if (!this._dateAdapter) {
throw createMissingDateImplError('DateAdapter');
}
Expand Down Expand Up @@ -371,7 +371,7 @@ export class MatDatepicker<D> implements OnDestroy, CanColor {
throw Error('Attempted to open an MatDatepicker with no associated input.');
}
if (this._document) {
this._focusedElementBeforeOpen = this._document.activeElement as HTMLElement;
this._focusedElementBeforeOpen = this._document.activeElement;
}

this.touchUi ? this._openAsDialog() : this._openAsPopup();
Expand Down
2 changes: 1 addition & 1 deletion src/lib/dialog/dialog-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class MatDialogContainer extends BasePortalOutlet {
private _elementRef: ElementRef,
private _focusTrapFactory: FocusTrapFactory,
private _changeDetectorRef: ChangeDetectorRef,
@Optional() @Inject(DOCUMENT) private _document: Document) {
@Optional() @Inject(DOCUMENT) private _document: any) {

super();
}
Expand Down
6 changes: 5 additions & 1 deletion src/lib/icon/icon-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ class SvgIconConfig {
*/
@Injectable({providedIn: 'root'})
export class MatIconRegistry {
private _document: Document;

/**
* URLs and cached SVG elements for individual icons. Keys are of the format "[namespace]:[icon]".
*/
Expand Down Expand Up @@ -124,7 +126,9 @@ export class MatIconRegistry {
constructor(
@Optional() private _httpClient: HttpClient,
private _sanitizer: DomSanitizer,
@Optional() @Inject(DOCUMENT) private _document: Document) {}
@Optional() @Inject(DOCUMENT) document: any) {
this._document = document;
}

/**
* Registers an icon by URL in the default namespace.
Expand Down
2 changes: 1 addition & 1 deletion src/lib/menu/menu-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class MatMenuContent implements OnDestroy {
private _appRef: ApplicationRef,
private _injector: Injector,
private _viewContainerRef: ViewContainerRef,
@Inject(DOCUMENT) private _document: Document) {}
@Inject(DOCUMENT) private _document: any) {}

/**
* Attaches the content with a particular context.
Expand Down
4 changes: 2 additions & 2 deletions src/lib/progress-spinner/progress-spinner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements

constructor(public _elementRef: ElementRef,
platform: Platform,
@Optional() @Inject(DOCUMENT) private _document: Document) {
@Optional() @Inject(DOCUMENT) private _document: any) {

super(_elementRef);
this._fallbackAnimation = platform.EDGE || platform.TRIDENT;
Expand Down Expand Up @@ -244,7 +244,7 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
})
export class MatSpinner extends MatProgressSpinner {
constructor(elementRef: ElementRef, platform: Platform,
@Optional() @Inject(DOCUMENT) document: Document) {
@Optional() @Inject(DOCUMENT) document: any) {
super(elementRef, platform, document);
this.mode = 'indeterminate';
}
Expand Down