diff --git a/src/lib/datepicker/calendar.html b/src/lib/datepicker/calendar.html
index 244a6640bda5..d6f507bc0c24 100644
--- a/src/lib/datepicker/calendar.html
+++ b/src/lib/datepicker/calendar.html
@@ -1,16 +1,42 @@
diff --git a/src/lib/datepicker/calendar.spec.ts b/src/lib/datepicker/calendar.spec.ts
index f632b4f204e1..2da229f7578c 100644
--- a/src/lib/datepicker/calendar.spec.ts
+++ b/src/lib/datepicker/calendar.spec.ts
@@ -23,6 +23,8 @@ import {
} from '../core/keyboard/keycodes';
import {MdDatepickerIntl} from './datepicker-intl';
import {MdNativeDateModule} from '../core/datetime/index';
+import {NoConflictStyleCompatibilityMode} from '../core';
+import {MdButtonModule} from '../button/index';
// When constructing a Date, the month is zero-based. This can be confusing, since people are
@@ -35,6 +37,7 @@ describe('MdCalendar', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
+ MdButtonModule,
MdNativeDateModule,
],
declarations: [
@@ -444,8 +447,6 @@ describe('MdCalendar', () => {
let fixture: ComponentFixture;
let testComponent: CalendarWithMinMax;
let calendarElement: HTMLElement;
- let prevButton: HTMLButtonElement;
- let nextButton: HTMLButtonElement;
let calendarInstance: MdCalendar;
beforeEach(() => {
@@ -453,9 +454,6 @@ describe('MdCalendar', () => {
let calendarDebugElement = fixture.debugElement.query(By.directive(MdCalendar));
calendarElement = calendarDebugElement.nativeElement;
- prevButton =
- calendarElement.querySelector('.mat-calendar-previous-button') as HTMLButtonElement;
- nextButton = calendarElement.querySelector('.mat-calendar-next-button') as HTMLButtonElement;
calendarInstance = calendarDebugElement.componentInstance;
testComponent = fixture.componentInstance;
});
@@ -478,6 +476,9 @@ describe('MdCalendar', () => {
testComponent.startAt = new Date(2016, FEB, 1);
fixture.detectChanges();
+ let prevButton =
+ calendarElement.querySelector('.mat-calendar-previous-button') as HTMLButtonElement;
+
expect(prevButton.disabled).toBe(false, 'previous button should not be disabled');
expect(calendarInstance._activeDate).toEqual(new Date(2016, FEB, 1));
@@ -497,6 +498,9 @@ describe('MdCalendar', () => {
testComponent.startAt = new Date(2017, DEC, 1);
fixture.detectChanges();
+ let nextButton =
+ calendarElement.querySelector('.mat-calendar-next-button') as HTMLButtonElement;
+
expect(nextButton.disabled).toBe(false, 'next button should not be disabled');
expect(calendarInstance._activeDate).toEqual(new Date(2017, DEC, 1));
@@ -584,6 +588,37 @@ describe('MdCalendar', () => {
});
});
+describe('MdCalendar in compatibility mode', () => {
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ imports: [
+ MdButtonModule,
+ MdNativeDateModule,
+ NoConflictStyleCompatibilityMode,
+ ],
+ declarations: [
+ MdCalendar,
+ MdCalendarBody,
+ MdMonthView,
+ MdYearView,
+
+ // Test components.
+ StandardCalendar,
+ ],
+ providers: [
+ MdDatepickerIntl,
+ ],
+ });
+
+ TestBed.compileComponents();
+ }));
+
+ it('should not throw on creation', () => {
+ let fixture = TestBed.createComponent(StandardCalendar);
+ expect(() => fixture.detectChanges()).not.toThrow();
+ });
+});
+
@Component({
template: ``
diff --git a/src/lib/datepicker/calendar.ts b/src/lib/datepicker/calendar.ts
index 9c6905a7f02d..faff96fec542 100644
--- a/src/lib/datepicker/calendar.ts
+++ b/src/lib/datepicker/calendar.ts
@@ -26,6 +26,7 @@ import {DateAdapter} from '../core/datetime/index';
import {MdDatepickerIntl} from './datepicker-intl';
import {createMissingDateImplError} from './datepicker-errors';
import {MD_DATE_FORMATS, MdDateFormats} from '../core/datetime/date-formats';
+import {MATERIAL_COMPATIBILITY_MODE} from '../core';
/**
@@ -111,6 +112,7 @@ export class MdCalendar implements AfterContentInit {
constructor(private _elementRef: ElementRef,
private _intl: MdDatepickerIntl,
private _ngZone: NgZone,
+ @Optional() @Inject(MATERIAL_COMPATIBILITY_MODE) public _isCompatibilityMode: boolean,
@Optional() private _dateAdapter: DateAdapter,
@Optional() @Inject(MD_DATE_FORMATS) private _dateFormats: MdDateFormats) {
if (!this._dateAdapter) {