diff --git a/src/lib/core/compatibility/compatibility.ts b/src/lib/core/compatibility/compatibility.ts index e38237937693..7bb8ee9eea1d 100644 --- a/src/lib/core/compatibility/compatibility.ts +++ b/src/lib/core/compatibility/compatibility.ts @@ -5,7 +5,9 @@ import { OpaqueToken, Inject, Optional, + isDevMode, } from '@angular/core'; +import {DOCUMENT} from '@angular/platform-browser'; export const MATERIAL_COMPATIBILITY_MODE = new OpaqueToken('md-compatibility-mode'); @@ -71,7 +73,7 @@ export const MAT_ELEMENTS_SELECTOR = ` mat-toolbar`; /** Selector that matches all elements that may have style collisions with AngularJS Material. */ -export const MD_ELEMENTS_SELECTOR = ` +export const MD_ELEMENTS_SELECTOR = ` [md-button], [md-dialog-actions], [md-dialog-close], @@ -167,6 +169,15 @@ export class CompatibilityModule { providers: [], }; } + + constructor(@Optional() @Inject(DOCUMENT) document: any) { + if (isDevMode() && typeof document && !document.doctype) { + console.warn( + 'Current document does not have a doctype. This may cause ' + + 'some Angular Material components not to behave as expected.' + ); + } + } }