mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
refactor(datepicker): remove 6.0.0 deletion targets (#10413)
Removes the deletion targets for 6.0.0 from `material/datepicker`. BREAKING CHANGES: * `selectedChanged` has been removed. Use `dateChange` or `dateInput` from `MatDatepickerInput`.
This commit is contained in:
committed by
Andrew Seguin
parent
f0bf6e7b28
commit
8bc7ee9ce5
@@ -254,14 +254,13 @@ export class MatDatepickerInput<D> implements AfterContentInit, ControlValueAcce
|
||||
|
||||
ngAfterContentInit() {
|
||||
if (this._datepicker) {
|
||||
this._datepickerSubscription =
|
||||
this._datepicker.selectedChanged.subscribe((selected: D) => {
|
||||
this.value = selected;
|
||||
this._cvaOnChange(selected);
|
||||
this._onTouched();
|
||||
this.dateInput.emit(new MatDatepickerInputEvent(this, this._elementRef.nativeElement));
|
||||
this.dateChange.emit(new MatDatepickerInputEvent(this, this._elementRef.nativeElement));
|
||||
});
|
||||
this._datepickerSubscription = this._datepicker._selectedChanged.subscribe((selected: D) => {
|
||||
this.value = selected;
|
||||
this._cvaOnChange(selected);
|
||||
this._onTouched();
|
||||
this.dateInput.emit(new MatDatepickerInputEvent(this, this._elementRef.nativeElement));
|
||||
this.dateChange.emit(new MatDatepickerInputEvent(this, this._elementRef.nativeElement));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -232,7 +232,7 @@ describe('MatDatepicker', () => {
|
||||
it('clicking the currently selected date should close the calendar ' +
|
||||
'without firing selectedChanged', fakeAsync(() => {
|
||||
const selectedChangedSpy =
|
||||
spyOn(testComponent.datepicker.selectedChanged, 'emit').and.callThrough();
|
||||
spyOn(testComponent.datepicker._selectedChanged, 'next').and.callThrough();
|
||||
|
||||
for (let changeCount = 1; changeCount < 3; changeCount++) {
|
||||
const currentDay = changeCount;
|
||||
@@ -256,7 +256,7 @@ describe('MatDatepicker', () => {
|
||||
it('pressing enter on the currently selected date should close the calendar without ' +
|
||||
'firing selectedChanged', () => {
|
||||
const selectedChangedSpy =
|
||||
spyOn(testComponent.datepicker.selectedChanged, 'emit').and.callThrough();
|
||||
spyOn(testComponent.datepicker._selectedChanged, 'next').and.callThrough();
|
||||
|
||||
testComponent.datepicker.open();
|
||||
fixture.detectChanges();
|
||||
|
||||
@@ -236,13 +236,6 @@ export class MatDatepicker<D> implements OnDestroy, CanColor {
|
||||
}
|
||||
private _disabled: boolean;
|
||||
|
||||
/**
|
||||
* Emits new selected date when selected date changes.
|
||||
* @deprecated Switch to the `dateChange` and `dateInput` binding on the input element.
|
||||
* @deletion-target 6.0.0
|
||||
*/
|
||||
@Output() readonly selectedChanged: EventEmitter<D> = new EventEmitter<D>();
|
||||
|
||||
/**
|
||||
* Emits selected year in multiyear view.
|
||||
* This doesn't imply a change on the selected date.
|
||||
@@ -317,6 +310,9 @@ export class MatDatepicker<D> implements OnDestroy, CanColor {
|
||||
/** Emits when the datepicker is disabled. */
|
||||
readonly _disabledChange = new Subject<boolean>();
|
||||
|
||||
/** Emits new selected date when selected date changes. */
|
||||
readonly _selectedChanged = new Subject<D>();
|
||||
|
||||
constructor(private _dialog: MatDialog,
|
||||
private _overlay: Overlay,
|
||||
private _ngZone: NgZone,
|
||||
@@ -346,7 +342,7 @@ export class MatDatepicker<D> implements OnDestroy, CanColor {
|
||||
let oldValue = this._selected;
|
||||
this._selected = date;
|
||||
if (!this._dateAdapter.sameDate(oldValue, this._selected)) {
|
||||
this.selectedChanged.emit(date);
|
||||
this._selectedChanged.next(date);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user