Skip to content

Commit d3fb8cf

Browse files
committed
fix: delay on-load sanity checks
Delays the sanity checks from the `CompatibilityModule` by 5 seconds, in order to give the user's base styles a better chance to load. Fixes #4125.
1 parent 8d0cd04 commit d3fb8cf

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/lib/core/compatibility/compatibility.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
Optional,
88
isDevMode,
99
ElementRef,
10+
NgZone,
1011
} from '@angular/core';
1112
import {DOCUMENT} from '@angular/platform-browser';
1213
import {MdError} from '../errors/error';
@@ -193,11 +194,16 @@ export class CompatibilityModule {
193194
};
194195
}
195196

196-
constructor(@Optional() @Inject(DOCUMENT) private _document: any) {
197+
constructor(@Optional() @Inject(DOCUMENT) private _document: any, ngZone: NgZone) {
197198
if (!hasDoneGlobalChecks && isDevMode()) {
198-
this._checkDoctype();
199-
this._checkTheme();
200-
hasDoneGlobalChecks = true;
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

0 commit comments

Comments
 (0)