File tree 1 file changed +4
-2
lines changed
src/lib/core/common-behaviors 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -72,15 +72,17 @@ export class MatCommonModule {
72
72
}
73
73
74
74
private _checkThemeIsPresent ( ) : void {
75
- if ( this . _document && typeof getComputedStyle === 'function' ) {
75
+ // We need to assert that the `body` is defined, because these checks run very early
76
+ // and the `body` won't be defined if the consumer put their scripts in the `head`.
77
+ if ( this . _document && this . _document . body && typeof getComputedStyle === 'function' ) {
76
78
const testElement = this . _document . createElement ( 'div' ) ;
77
79
78
80
testElement . classList . add ( 'mat-theme-loaded-marker' ) ;
79
81
this . _document . body . appendChild ( testElement ) ;
80
82
81
83
const computedStyle = getComputedStyle ( testElement ) ;
82
84
83
- // In some situations, the computed style of the test element can be null. For example in
85
+ // In some situations the computed style of the test element can be null. For example in
84
86
// Firefox, the computed style is null if an application is running inside of a hidden iframe.
85
87
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=548397
86
88
if ( computedStyle && computedStyle . display !== 'none' ) {
You can’t perform that action at this time.
0 commit comments