Skip to content

Commit adb31c2

Browse files
authored
refactor(material/tooltip): change deprecated APIs for v12 (#21897)
Changes the APIs that were marked as deprecated for v12. BREAKING CHANGES: * The `_document` parameter of the `MatTooltip` constructor is now required.
1 parent 46ebbad commit adb31c2

File tree

4 files changed

+12
-18
lines changed

4 files changed

+12
-18
lines changed

src/material-experimental/mdc-tooltip/tooltip.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ export class MatTooltip extends _MatTooltipBase<TooltipComponent> {
6262
@Inject(MAT_TOOLTIP_SCROLL_STRATEGY) scrollStrategy: any,
6363
@Optional() dir: Directionality,
6464
@Optional() @Inject(MAT_TOOLTIP_DEFAULT_OPTIONS) defaultOptions: MatTooltipDefaultOptions,
65-
66-
/** @breaking-change 11.0.0 _document argument to become required. */
6765
@Inject(DOCUMENT) _document: any) {
6866

6967
super(overlay, elementRef, scrollDispatcher, viewContainerRef, ngZone, platform, ariaDescriber,

src/material/schematics/ng-update/data/constructor-checks.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ import {ConstructorChecksUpgradeData, TargetVersion, VersionChanges} from '@angu
1414
* automatically through type checking.
1515
*/
1616
export const constructorChecks: VersionChanges<ConstructorChecksUpgradeData> = {
17+
[TargetVersion.V12]: [
18+
{
19+
pr: 'https://github.com/angular/components/pull/21897',
20+
changes: ['MatTooltip']
21+
}
22+
],
1723
[TargetVersion.V11]: [
1824
{
1925
pr: 'https://github.com/angular/components/issues/20463',

src/material/tooltip/tooltip.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,8 @@ export abstract class _MatTooltipBase<T extends _TooltipComponentBase> implement
242242
private readonly _passiveListeners:
243243
(readonly [string, EventListenerOrEventListenerObject])[] = [];
244244

245-
/**
246-
* Reference to the current document.
247-
* @breaking-change 11.0.0 Remove `| null` typing for `document`.
248-
*/
249-
private _document: Document | null;
245+
/** Reference to the current document. */
246+
private _document: Document;
250247

251248
/** Timer started at the last `touchstart` event. */
252249
private _touchstartTimeout: number;
@@ -266,11 +263,10 @@ export abstract class _MatTooltipBase<T extends _TooltipComponentBase> implement
266263
scrollStrategy: any,
267264
protected _dir: Directionality,
268265
private _defaultOptions: MatTooltipDefaultOptions,
269-
270-
/** @breaking-change 11.0.0 _document argument to become required. */
271266
@Inject(DOCUMENT) _document: any) {
272267

273268
this._scrollStrategy = scrollStrategy;
269+
this._document = _document;
274270

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

679673
// On non-touch devices we depend on the `mouseleave` event to close the tooltip, but it
@@ -746,8 +740,6 @@ export class MatTooltip extends _MatTooltipBase<TooltipComponent> {
746740
@Inject(MAT_TOOLTIP_SCROLL_STRATEGY) scrollStrategy: any,
747741
@Optional() dir: Directionality,
748742
@Optional() @Inject(MAT_TOOLTIP_DEFAULT_OPTIONS) defaultOptions: MatTooltipDefaultOptions,
749-
750-
/** @breaking-change 11.0.0 _document argument to become required. */
751743
@Inject(DOCUMENT) _document: any) {
752744

753745
super(overlay, elementRef, scrollDispatcher, viewContainerRef, ngZone, platform, ariaDescriber,

tools/public_api_guard/material/tooltip.d.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ export declare abstract class _MatTooltipBase<T extends _TooltipComponentBase> i
2020
[key: string]: any;
2121
});
2222
touchGestures: TooltipTouchGestures;
23-
constructor(_overlay: Overlay, _elementRef: ElementRef<HTMLElement>, _scrollDispatcher: ScrollDispatcher, _viewContainerRef: ViewContainerRef, _ngZone: NgZone, _platform: Platform, _ariaDescriber: AriaDescriber, _focusMonitor: FocusMonitor, scrollStrategy: any, _dir: Directionality, _defaultOptions: MatTooltipDefaultOptions,
24-
_document: any);
23+
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);
2524
protected _addOffset(position: ConnectedPosition): ConnectedPosition;
2625
_getOrigin(): {
2726
main: OriginConnectionPosition;
@@ -85,8 +84,7 @@ export declare const MAT_TOOLTIP_SCROLL_STRATEGY_FACTORY_PROVIDER: {
8584
export declare class MatTooltip extends _MatTooltipBase<TooltipComponent> {
8685
protected readonly _tooltipComponent: typeof TooltipComponent;
8786
protected readonly _transformOriginSelector = ".mat-tooltip";
88-
constructor(overlay: Overlay, elementRef: ElementRef<HTMLElement>, scrollDispatcher: ScrollDispatcher, viewContainerRef: ViewContainerRef, ngZone: NgZone, platform: Platform, ariaDescriber: AriaDescriber, focusMonitor: FocusMonitor, scrollStrategy: any, dir: Directionality, defaultOptions: MatTooltipDefaultOptions,
89-
_document: any);
87+
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);
9088
static ɵdir: i0.ɵɵDirectiveDefWithMeta<MatTooltip, "[matTooltip]", ["matTooltip"], {}, {}, never>;
9189
static ɵfac: i0.ɵɵFactoryDef<MatTooltip, [null, null, null, null, null, null, null, null, null, { optional: true; }, { optional: true; }, null]>;
9290
}

0 commit comments

Comments
 (0)