Skip to content

Commit

Permalink
fix(datepicker): make sure _datepickerInput exists before accessing i…
Browse files Browse the repository at this point in the history
…ts (#7033)

* fix(datepicker): make sure _datepickerInput exists before accessing its
disabled property.

* add test
  • Loading branch information
mmalerba authored and andrewseguin committed Sep 29, 2017
1 parent 2dcb76c commit 2129b7a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/lib/datepicker/datepicker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}));
Expand Down
3 changes: 2 additions & 1 deletion src/lib/datepicker/datepicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2129b7a

Please sign in to comment.