Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): log warning if doctype is missing #2849

Merged
merged 1 commit into from
Mar 20, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/lib/core/compatibility/compatibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -167,6 +169,15 @@ export class CompatibilityModule {
providers: [],
};
}

constructor(@Optional() @Inject(DOCUMENT) document: any) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type of document is just Document

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, but my worry was that it would complain about it in a Universal app.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I didn't realize Document was a browser global

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.'
);
}
}
}


Expand Down