mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(datepicker): make sure _datepickerInput exists before accessing its (#7033)
* fix(datepicker): make sure _datepickerInput exists before accessing its disabled property. * add test
This commit is contained in:
@@ -304,6 +304,10 @@ describe('MatDatepicker', () => {
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
it('should not throw when accessing disabled property', () => {
|
||||
expect(() => testComponent.datepicker.disabled).not.toThrow();
|
||||
});
|
||||
|
||||
it('should throw when opened with no registered inputs', async(() => {
|
||||
expect(() => testComponent.datepicker.open()).toThrow();
|
||||
}));
|
||||
|
||||
@@ -147,7 +147,8 @@ export class MatDatepicker<D> implements OnDestroy {
|
||||
/** Whether the datepicker pop-up should be disabled. */
|
||||
@Input()
|
||||
get disabled() {
|
||||
return this._disabled === undefined ? this._datepickerInput.disabled : this._disabled;
|
||||
return this._disabled === undefined && this._datepickerInput ?
|
||||
this._datepickerInput.disabled : this._disabled;
|
||||
}
|
||||
set disabled(value: any) {
|
||||
const newValue = coerceBooleanProperty(value);
|
||||
|
||||
Reference in New Issue
Block a user