Skip to content

refactor(material/tooltip): change deprecated APIs for v12 #21897

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
Feb 18, 2021
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: 0 additions & 2 deletions src/material-experimental/mdc-tooltip/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ export class MatTooltip extends _MatTooltipBase<TooltipComponent> {
@Inject(MAT_TOOLTIP_SCROLL_STRATEGY) scrollStrategy: any,
@Optional() dir: Directionality,
@Optional() @Inject(MAT_TOOLTIP_DEFAULT_OPTIONS) defaultOptions: MatTooltipDefaultOptions,

/** @breaking-change 11.0.0 _document argument to become required. */
@Inject(DOCUMENT) _document: any) {

super(overlay, elementRef, scrollDispatcher, viewContainerRef, ngZone, platform, ariaDescriber,
Expand Down
6 changes: 6 additions & 0 deletions src/material/schematics/ng-update/data/constructor-checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ import {ConstructorChecksUpgradeData, TargetVersion, VersionChanges} from '@angu
* automatically through type checking.
*/
export const constructorChecks: VersionChanges<ConstructorChecksUpgradeData> = {
[TargetVersion.V12]: [
{
pr: 'https://github.com/angular/components/pull/21897',
changes: ['MatTooltip']
}
],
[TargetVersion.V11]: [
{
pr: 'https://github.com/angular/components/issues/20463',
Expand Down
16 changes: 4 additions & 12 deletions src/material/tooltip/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,8 @@ export abstract class _MatTooltipBase<T extends _TooltipComponentBase> implement
private readonly _passiveListeners:
(readonly [string, EventListenerOrEventListenerObject])[] = [];

/**
* Reference to the current document.
* @breaking-change 11.0.0 Remove `| null` typing for `document`.
*/
private _document: Document | null;
/** Reference to the current document. */
private _document: Document;

/** Timer started at the last `touchstart` event. */
private _touchstartTimeout: number;
Expand All @@ -266,11 +263,10 @@ export abstract class _MatTooltipBase<T extends _TooltipComponentBase> implement
scrollStrategy: any,
protected _dir: Directionality,
private _defaultOptions: MatTooltipDefaultOptions,

/** @breaking-change 11.0.0 _document argument to become required. */
@Inject(DOCUMENT) _document: any) {

this._scrollStrategy = scrollStrategy;
this._document = _document;

if (_defaultOptions) {
if (_defaultOptions.position) {
Expand Down Expand Up @@ -671,9 +667,7 @@ export abstract class _MatTooltipBase<T extends _TooltipComponentBase> implement
/** Listener for the `wheel` event on the element. */
private _wheelListener(event: WheelEvent) {
if (this._isTooltipVisible()) {
// @breaking-change 11.0.0 Remove `|| document` once the document is a required param.
const doc = this._document || document;
const elementUnderPointer = doc.elementFromPoint(event.clientX, event.clientY);
const elementUnderPointer = this._document.elementFromPoint(event.clientX, event.clientY);
const element = this._elementRef.nativeElement;

// On non-touch devices we depend on the `mouseleave` event to close the tooltip, but it
Expand Down Expand Up @@ -746,8 +740,6 @@ export class MatTooltip extends _MatTooltipBase<TooltipComponent> {
@Inject(MAT_TOOLTIP_SCROLL_STRATEGY) scrollStrategy: any,
@Optional() dir: Directionality,
@Optional() @Inject(MAT_TOOLTIP_DEFAULT_OPTIONS) defaultOptions: MatTooltipDefaultOptions,

/** @breaking-change 11.0.0 _document argument to become required. */
@Inject(DOCUMENT) _document: any) {

super(overlay, elementRef, scrollDispatcher, viewContainerRef, ngZone, platform, ariaDescriber,
Expand Down
6 changes: 2 additions & 4 deletions tools/public_api_guard/material/tooltip.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ export declare abstract class _MatTooltipBase<T extends _TooltipComponentBase> i
[key: string]: any;
});
touchGestures: TooltipTouchGestures;
constructor(_overlay: Overlay, _elementRef: ElementRef<HTMLElement>, _scrollDispatcher: ScrollDispatcher, _viewContainerRef: ViewContainerRef, _ngZone: NgZone, _platform: Platform, _ariaDescriber: AriaDescriber, _focusMonitor: FocusMonitor, scrollStrategy: any, _dir: Directionality, _defaultOptions: MatTooltipDefaultOptions,
_document: any);
constructor(_overlay: Overlay, _elementRef: ElementRef<HTMLElement>, _scrollDispatcher: ScrollDispatcher, _viewContainerRef: ViewContainerRef, _ngZone: NgZone, _platform: Platform, _ariaDescriber: AriaDescriber, _focusMonitor: FocusMonitor, scrollStrategy: any, _dir: Directionality, _defaultOptions: MatTooltipDefaultOptions, _document: any);
protected _addOffset(position: ConnectedPosition): ConnectedPosition;
_getOrigin(): {
main: OriginConnectionPosition;
Expand Down Expand Up @@ -85,8 +84,7 @@ export declare const MAT_TOOLTIP_SCROLL_STRATEGY_FACTORY_PROVIDER: {
export declare class MatTooltip extends _MatTooltipBase<TooltipComponent> {
protected readonly _tooltipComponent: typeof TooltipComponent;
protected readonly _transformOriginSelector = ".mat-tooltip";
constructor(overlay: Overlay, elementRef: ElementRef<HTMLElement>, scrollDispatcher: ScrollDispatcher, viewContainerRef: ViewContainerRef, ngZone: NgZone, platform: Platform, ariaDescriber: AriaDescriber, focusMonitor: FocusMonitor, scrollStrategy: any, dir: Directionality, defaultOptions: MatTooltipDefaultOptions,
_document: any);
constructor(overlay: Overlay, elementRef: ElementRef<HTMLElement>, scrollDispatcher: ScrollDispatcher, viewContainerRef: ViewContainerRef, ngZone: NgZone, platform: Platform, ariaDescriber: AriaDescriber, focusMonitor: FocusMonitor, scrollStrategy: any, dir: Directionality, defaultOptions: MatTooltipDefaultOptions, _document: any);
static ɵdir: i0.ɵɵDirectiveDefWithMeta<MatTooltip, "[matTooltip]", ["matTooltip"], {}, {}, never>;
static ɵfac: i0.ɵɵFactoryDef<MatTooltip, [null, null, null, null, null, null, null, null, null, { optional: true; }, { optional: true; }, null]>;
}
Expand Down