Skip to content

refactor(slide-toggle): remove deprecated APIs for version 10 #19307

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
May 13, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ import {InjectionToken} from '@angular/core';
export interface MatSlideToggleDefaultOptions {
/** Whether toggle action triggers value changes in slide toggle. */
disableToggleValue?: boolean;
/**
* Whether drag action triggers value changes in slide toggle.
* @deprecated No longer being used.
* @breaking-change 9.0.0.
*/
disableDragValue?: boolean;
}

/** Injection token to be used to override the default options for `mat-slide-toggle`. */
Expand Down
10 changes: 0 additions & 10 deletions src/material-experimental/mdc-slide-toggle/slide-toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,6 @@ export class MatSlideToggle implements ControlValueAccessor, AfterViewInit, OnDe
/** Event will be dispatched each time the slide-toggle input is toggled. */
@Output() readonly toggleChange: EventEmitter<void> = new EventEmitter<void>();

/**
* An event will be dispatched each time the slide-toggle is dragged.
* This event is always emitted when the user drags the slide toggle to make a change greater
* than 50%. It does not mean the slide toggle's value is changed. The event is not emitted when
* the user toggles the slide toggle to change its value.
* @deprecated No longer being used.
* @breaking-change 9.0.0
*/
@Output() readonly dragChange: EventEmitter<void> = new EventEmitter<void>();

/** Returns the unique id for the visual hidden input. */
get inputId(): string { return `${this.id || this._uniqueId}-input`; }

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.V10]: [
{
pr: 'https://github.com/angular/components/pull/19307',
changes: ['MatSlideToggle']
}
],
[TargetVersion.V9]: [
{
pr: 'https://github.com/angular/components/pull/17230',
Expand Down
2 changes: 0 additions & 2 deletions src/material/slide-toggle/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ ng_module(
module_name = "@angular/material/slide-toggle",
deps = [
"//src/cdk/a11y",
"//src/cdk/bidi",
"//src/cdk/coercion",
"//src/cdk/observers",
"//src/material/core",
Expand Down Expand Up @@ -57,7 +56,6 @@ ng_test_library(
deps = [
":slide-toggle",
"//src/cdk/a11y",
"//src/cdk/bidi",
"//src/cdk/observers",
"//src/cdk/testing/private",
"//src/material/testing",
Expand Down
6 changes: 0 additions & 6 deletions src/material/slide-toggle/slide-toggle-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ import {InjectionToken} from '@angular/core';
export interface MatSlideToggleDefaultOptions {
/** Whether toggle action triggers value changes in slide toggle. */
disableToggleValue?: boolean;
/**
* Whether drag action triggers value changes in slide toggle.
* @deprecated No longer being used.
* @breaking-change 10.0.0
*/
disableDragValue?: boolean;
}

/** Injection token to be used to override the default options for `mat-slide-toggle`. */
Expand Down
6 changes: 2 additions & 4 deletions src/material/slide-toggle/slide-toggle.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {BidiModule, Direction} from '@angular/cdk/bidi';
import {MutationObserverFactory} from '@angular/cdk/observers';
import {dispatchFakeEvent} from '@angular/cdk/testing/private';
import {Component} from '@angular/core';
Expand All @@ -25,7 +24,7 @@ describe('MatSlideToggle without forms', () => {
mutationObserverCallbacks = [];

TestBed.configureTestingModule({
imports: [MatSlideToggleModule, BidiModule],
imports: [MatSlideToggleModule],
declarations: [
SlideToggleBasic,
SlideToggleWithTabindexAttr,
Expand Down Expand Up @@ -850,7 +849,7 @@ describe('MatSlideToggle with forms', () => {

@Component({
template: `
<mat-slide-toggle [dir]="direction" [required]="isRequired"
<mat-slide-toggle [required]="isRequired"
[disabled]="isDisabled"
[color]="slideColor"
[id]="slideId"
Expand Down Expand Up @@ -883,7 +882,6 @@ class SlideToggleBasic {
labelPosition: string;
toggleTriggered: number = 0;
dragTriggered: number = 0;
direction: Direction = 'ltr';

onSlideClick: (event?: Event) => void = () => {};
onSlideChange = (event: MatSlideToggleChange) => this.lastEvent = event;
Expand Down
20 changes: 1 addition & 19 deletions src/material/slide-toggle/slide-toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

import {FocusMonitor} from '@angular/cdk/a11y';
import {Directionality} from '@angular/cdk/bidi';
import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion';
import {
AfterContentInit,
Expand All @@ -23,7 +22,6 @@ import {
Output,
ViewChild,
ViewEncapsulation,
NgZone,
Optional,
Inject,
} from '@angular/core';
Expand Down Expand Up @@ -155,16 +153,6 @@ export class MatSlideToggle extends _MatSlideToggleMixinBase implements OnDestro
*/
@Output() readonly toggleChange: EventEmitter<void> = new EventEmitter<void>();

/**
* An event will be dispatched each time the slide-toggle is dragged.
* This event is always emitted when the user drags the slide toggle to make a change greater
* than 50%. It does not mean the slide toggle's value is changed. The event is not emitted when
* the user toggles the slide toggle to change its value.
* @deprecated No longer being used. To be removed.
* @breaking-change 10.0.0
*/
@Output() readonly dragChange: EventEmitter<void> = new EventEmitter<void>();

/** Returns the unique id for the visual hidden input. */
get inputId(): string { return `${this.id || this._uniqueId}-input`; }

Expand All @@ -175,15 +163,9 @@ export class MatSlideToggle extends _MatSlideToggleMixinBase implements OnDestro
private _focusMonitor: FocusMonitor,
private _changeDetectorRef: ChangeDetectorRef,
@Attribute('tabindex') tabIndex: string,
/**
* @deprecated `_ngZone` and `_dir` parameters to be removed.
* @breaking-change 10.0.0
*/
_ngZone: NgZone,
@Inject(MAT_SLIDE_TOGGLE_DEFAULT_OPTIONS)
public defaults: MatSlideToggleDefaultOptions,
@Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string,
@Optional() _dir?: Directionality) {
@Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string) {
super(elementRef);
this.tabIndex = parseInt(tabIndex) || 0;
}
Expand Down
9 changes: 3 additions & 6 deletions tools/public_api_guard/material/slide-toggle.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@ export declare class MatSlideToggle extends _MatSlideToggleMixinBase implements
get checked(): boolean;
set checked(value: boolean);
defaults: MatSlideToggleDefaultOptions;
readonly dragChange: EventEmitter<void>;
id: string;
get inputId(): string;
labelPosition: 'before' | 'after';
name: string | null;
get required(): boolean;
set required(value: boolean);
readonly toggleChange: EventEmitter<void>;
constructor(elementRef: ElementRef, _focusMonitor: FocusMonitor, _changeDetectorRef: ChangeDetectorRef, tabIndex: string,
_ngZone: NgZone, defaults: MatSlideToggleDefaultOptions, _animationMode?: string | undefined, _dir?: Directionality);
constructor(elementRef: ElementRef, _focusMonitor: FocusMonitor, _changeDetectorRef: ChangeDetectorRef, tabIndex: string, defaults: MatSlideToggleDefaultOptions, _animationMode?: string | undefined);
_onChangeEvent(event: Event): void;
_onInputClick(event: Event): void;
_onLabelTextChange(): void;
Expand All @@ -45,8 +43,8 @@ export declare class MatSlideToggle extends _MatSlideToggleMixinBase implements
static ngAcceptInputType_disableRipple: BooleanInput;
static ngAcceptInputType_disabled: BooleanInput;
static ngAcceptInputType_required: BooleanInput;
static ɵcmp: i0.ɵɵComponentDefWithMeta<MatSlideToggle, "mat-slide-toggle", ["matSlideToggle"], { "disabled": "disabled"; "disableRipple": "disableRipple"; "color": "color"; "tabIndex": "tabIndex"; "name": "name"; "id": "id"; "labelPosition": "labelPosition"; "ariaLabel": "aria-label"; "ariaLabelledby": "aria-labelledby"; "required": "required"; "checked": "checked"; }, { "change": "change"; "toggleChange": "toggleChange"; "dragChange": "dragChange"; }, never, ["*"]>;
static ɵfac: i0.ɵɵFactoryDef<MatSlideToggle, [null, null, null, { attribute: "tabindex"; }, null, null, { optional: true; }, { optional: true; }]>;
static ɵcmp: i0.ɵɵComponentDefWithMeta<MatSlideToggle, "mat-slide-toggle", ["matSlideToggle"], { "disabled": "disabled"; "disableRipple": "disableRipple"; "color": "color"; "tabIndex": "tabIndex"; "name": "name"; "id": "id"; "labelPosition": "labelPosition"; "ariaLabel": "aria-label"; "ariaLabelledby": "aria-labelledby"; "required": "required"; "checked": "checked"; }, { "change": "change"; "toggleChange": "toggleChange"; }, never, ["*"]>;
static ɵfac: i0.ɵɵFactoryDef<MatSlideToggle, [null, null, null, { attribute: "tabindex"; }, null, { optional: true; }]>;
}

export declare class MatSlideToggleChange {
Expand All @@ -58,7 +56,6 @@ export declare class MatSlideToggleChange {
}

export interface MatSlideToggleDefaultOptions {
disableDragValue?: boolean;
disableToggleValue?: boolean;
}

Expand Down