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 7
7
Optional ,
8
8
isDevMode ,
9
9
ElementRef ,
10
+ NgZone ,
10
11
} from '@angular/core' ;
11
12
import { DOCUMENT } from '@angular/platform-browser' ;
12
13
import { MdError } from '../errors/error' ;
@@ -193,16 +194,21 @@ export class CompatibilityModule {
193
194
} ;
194
195
}
195
196
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
+ } ) ;
201
207
}
202
208
}
203
209
204
210
private _checkDoctype ( ) : void {
205
- if ( this . _document && ! this . _document . doctype ) {
211
+ if ( ! this . _document . doctype ) {
206
212
console . warn (
207
213
'Current document does not have a doctype. This may cause ' +
208
214
'some Angular Material components not to behave as expected.'
@@ -211,7 +217,7 @@ export class CompatibilityModule {
211
217
}
212
218
213
219
private _checkTheme ( ) : void {
214
- if ( this . _document && typeof getComputedStyle === 'function' ) {
220
+ if ( typeof getComputedStyle === 'function' ) {
215
221
const testElement = this . _document . createElement ( 'div' ) ;
216
222
217
223
testElement . classList . add ( 'mat-theme-loaded-marker' ) ;
You can’t perform that action at this time.
0 commit comments