mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(core): log warning if doctype is missing (#2849)
Logs a warning if the user's document doesn't have a doctype. This has been an issue in the past with some hard-to-track-down bugs which ended up being due to the browser running in quirks mode. Fixes #2351.
This commit is contained in:
committed by
Jeremy Elbourn
parent
5c1474d610
commit
22b0660103
@@ -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.'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user