File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
lib/core/common-behaviors Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,9 @@ export class MatCommonModule {
3737 /** Reference to the global `document` object. */
3838 private _document = typeof document === 'object' && document ? document : null ;
3939
40+ /** Reference to the global 'window' object. */
41+ private _window = typeof window === 'object' && window ? window : null ;
42+
4043 constructor ( @Optional ( ) @Inject ( MATERIAL_SANITY_CHECKS ) private _sanityChecksEnabled : boolean ) {
4144 if ( this . _areChecksEnabled ( ) && ! this . _hasDoneGlobalChecks ) {
4245 this . _checkDoctypeIsDefined ( ) ;
@@ -52,7 +55,7 @@ export class MatCommonModule {
5255
5356 /** Whether the code is running in tests. */
5457 private _isTestEnv ( ) {
55- return window [ '__karma__' ] || window [ 'jasmine' ] ;
58+ return this . _window && ( this . _window [ '__karma__' ] || this . _window [ 'jasmine' ] ) ;
5659 }
5760
5861 private _checkDoctypeIsDefined ( ) : void {
@@ -90,7 +93,11 @@ export class MatCommonModule {
9093
9194 /** Checks whether HammerJS is available. */
9295 _checkHammerIsAvailable ( ) : void {
93- if ( this . _areChecksEnabled ( ) && ! this . _hasCheckedHammer && ! window [ 'Hammer' ] ) {
96+ if ( this . _hasCheckedHammer || ! this . _window ) {
97+ return ;
98+ }
99+
100+ if ( this . _areChecksEnabled ( ) && ! this . _window [ 'Hammer' ] ) {
94101 console . warn (
95102 'Could not find HammerJS. Certain Angular Material components may not work correctly.' ) ;
96103 }
Original file line number Diff line number Diff line change 1- import { enableProdMode } from '@angular/core' ;
21import { renderModuleFactory } from '@angular/platform-server' ;
32import { readFileSync , writeFileSync } from 'fs-extra' ;
43import { log } from 'gulp-util' ;
@@ -7,7 +6,8 @@ import 'reflect-metadata';
76import 'zone.js' ;
87import { KitchenSinkServerModuleNgFactory } from './kitchen-sink/kitchen-sink.ngfactory' ;
98
10- enableProdMode ( ) ;
9+ // Do not enable production mode, because otherwise the `MatCommonModule` won't execute
10+ // the browser related checks that could cause NodeJS issues.
1111
1212const result = renderModuleFactory ( KitchenSinkServerModuleNgFactory , {
1313 document : readFileSync ( join ( __dirname , 'index.html' ) , 'utf-8' )
You can’t perform that action at this time.
0 commit comments