Skip to content

Commit a69c108

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 c203589 commit a69c108

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/lib/dialog/dialog.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import {Injector, ComponentRef, Injectable, Optional, SkipSelf, TemplateRef} from '@angular/core';
1+
import {
2+
Injector,
3+
ComponentRef,
4+
Injectable,
5+
Optional,
6+
SkipSelf,
7+
TemplateRef,
8+
isDevMode,
9+
} from '@angular/core';
210
import {Observable} from 'rxjs/Observable';
311
import {Subject} from 'rxjs/Subject';
412
import {Overlay, OverlayRef, ComponentType, OverlayState, ComponentPortal} from '../core';
@@ -46,7 +54,15 @@ export class MdDialog {
4654
constructor(
4755
private _overlay: Overlay,
4856
private _injector: Injector,
49-
@Optional() @SkipSelf() private _parentDialog: MdDialog) { }
57+
@Optional() @SkipSelf() private _parentDialog: MdDialog) {
58+
59+
if (isDevMode() && typeof document !== 'undefined' && !document.doctype) {
60+
console.warn(
61+
'Current document does not have a doctype. This may cause ' +
62+
'the Angular Material dialog not to behave as expected.'
63+
);
64+
}
65+
}
5066

5167
/**
5268
* Opens a modal dialog containing the given component.

0 commit comments

Comments
 (0)