File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed
src/lib/core/compatibility Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change 77 Optional ,
88 isDevMode ,
99 ElementRef ,
10+ NgZone ,
1011} from '@angular/core' ;
1112import { DOCUMENT } from '@angular/platform-browser' ;
1213import { MdError } from '../errors/error' ;
@@ -193,16 +194,21 @@ export class CompatibilityModule {
193194 } ;
194195 }
195196
196- constructor ( @Optional ( ) @Inject ( DOCUMENT ) private _document : any ) {
197- if ( ! hasDoneGlobalChecks && isDevMode ( ) ) {
198- this . _checkDoctype ( ) ;
199- this . _checkTheme ( ) ;
200- hasDoneGlobalChecks = true ;
197+ constructor ( @Optional ( ) @Inject ( DOCUMENT ) private _document : any , ngZone : NgZone ) {
198+ if ( ! hasDoneGlobalChecks && _document && isDevMode ( ) ) {
199+ ngZone . runOutsideAngular ( ( ) => {
200+ // Delay running the check to allow more time for the user's styles to load.
201+ setTimeout ( ( ) => {
202+ this . _checkDoctype ( ) ;
203+ this . _checkTheme ( ) ;
204+ hasDoneGlobalChecks = true ;
205+ } , 5000 ) ;
206+ } ) ;
201207 }
202208 }
203209
204210 private _checkDoctype ( ) : void {
205- if ( this . _document && ! this . _document . doctype ) {
211+ if ( ! this . _document . doctype ) {
206212 console . warn (
207213 'Current document does not have a doctype. This may cause ' +
208214 'some Angular Material components not to behave as expected.'
@@ -211,7 +217,7 @@ export class CompatibilityModule {
211217 }
212218
213219 private _checkTheme ( ) : void {
214- if ( this . _document && typeof getComputedStyle === 'function' ) {
220+ if ( typeof getComputedStyle === 'function' ) {
215221 const testElement = this . _document . createElement ( 'div' ) ;
216222
217223 testElement . classList . add ( 'mat-theme-loaded-marker' ) ;
You can’t perform that action at this time.
0 commit comments