Skip to content

Commit

Permalink
fix(dialog): log warning if doctype is missing
Browse files Browse the repository at this point in the history
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 angular#2351.
  • Loading branch information
crisbeto committed Feb 24, 2017
1 parent c203589 commit a69c108
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/lib/dialog/dialog.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import {Injector, ComponentRef, Injectable, Optional, SkipSelf, TemplateRef} from '@angular/core';
import {
Injector,
ComponentRef,
Injectable,
Optional,
SkipSelf,
TemplateRef,
isDevMode,
} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Subject} from 'rxjs/Subject';
import {Overlay, OverlayRef, ComponentType, OverlayState, ComponentPortal} from '../core';
Expand Down Expand Up @@ -46,7 +54,15 @@ export class MdDialog {
constructor(
private _overlay: Overlay,
private _injector: Injector,
@Optional() @SkipSelf() private _parentDialog: MdDialog) { }
@Optional() @SkipSelf() private _parentDialog: MdDialog) {

if (isDevMode() && typeof document !== 'undefined' && !document.doctype) {
console.warn(
'Current document does not have a doctype. This may cause ' +
'the Angular Material dialog not to behave as expected.'
);
}
}

/**
* Opens a modal dialog containing the given component.
Expand Down

0 comments on commit a69c108

Please sign in to comment.