Skip to content

Commit 787ea0f

Browse files
committed
fix(dialog): log warning if doctype is missing
Logs a warning in the dialog service, if the doctype is missing. In such cases, the page is put into quirks mode, which causes the dialog to take up the entire height of the viewport, without much feedback regarding why. We can't really do much to work around the height issue in Material, however not adding a doctype isn't a good idea in general. Fixes #2351.
1 parent 3b6cab0 commit 787ea0f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/lib/dialog/dialog.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Injector, ComponentRef, Injectable, Optional, SkipSelf} from '@angular/core';
1+
import {Injector, ComponentRef, Injectable, Optional, SkipSelf, isDevMode} from '@angular/core';
22
import {Observable} from 'rxjs/Observable';
33
import {Subject} from 'rxjs/Subject';
44

@@ -49,7 +49,15 @@ export class MdDialog {
4949
constructor(
5050
private _overlay: Overlay,
5151
private _injector: Injector,
52-
@Optional() @SkipSelf() private _parentDialog: MdDialog) { }
52+
@Optional() @SkipSelf() private _parentDialog: MdDialog) {
53+
54+
if (isDevMode() && typeof document !== 'undefined' && !document.doctype) {
55+
console.warn(
56+
'Current document does not have a doctype. This may cause ' +
57+
'the Angular Material dialog not to behave as expected.'
58+
);
59+
}
60+
}
5361

5462
/**
5563
* Opens a modal dialog containing the given component.

0 commit comments

Comments
 (0)