@@ -90,13 +90,21 @@ export class MatCommonModule {
9090    return  typeof  win  ===  'object'  &&  win  ? win  : null ; 
9191  } 
9292
93-   /** Whether any  sanity checks are  enabled. */ 
94-   private  _checksAreEnabled ( ) : boolean  { 
93+   /** Gets whether a specific  sanity check is  enabled. */ 
94+   private  _checkIsEnabled ( name :  keyof   GranularSanityChecks ) : boolean  { 
9595    // TODO(crisbeto): we can't use `ngDevMode` here yet, because ViewEngine apps might not support 
9696    // it. Since these checks can have performance implications and they aren't tree shakeable 
9797    // in their current form, we can leave the `isDevMode` check in for now. 
9898    // tslint:disable-next-line:ban 
99-     return  isDevMode ( )  &&  ! this . _isTestEnv ( ) ; 
99+     if  ( ! isDevMode ( )  ||  this . _isTestEnv ( ) )  { 
100+       return  false ; 
101+     } 
102+ 
103+     if  ( typeof  this . _sanityChecks  ===  'boolean' )  { 
104+       return  this . _sanityChecks ; 
105+     } 
106+ 
107+     return  ! ! this . _sanityChecks [ name ] ; 
100108  } 
101109
102110  /** Whether the code is running in tests. */ 
@@ -106,10 +114,7 @@ export class MatCommonModule {
106114  } 
107115
108116  private  _checkDoctypeIsDefined ( ) : void { 
109-     const  isEnabled  =  this . _checksAreEnabled ( )  && 
110-       ( this . _sanityChecks  ===  true  ||  ( this . _sanityChecks  as  GranularSanityChecks ) . doctype ) ; 
111- 
112-     if  ( isEnabled  &&  ! this . _document . doctype )  { 
117+     if  ( this . _checkIsEnabled ( 'doctype' )  &&  ! this . _document . doctype )  { 
113118      console . warn ( 
114119        'Current document does not have a doctype. This may cause '  + 
115120        'some Angular Material components not to behave as expected.' 
@@ -120,10 +125,8 @@ export class MatCommonModule {
120125  private  _checkThemeIsPresent ( ) : void { 
121126    // We need to assert that the `body` is defined, because these checks run very early 
122127    // and the `body` won't be defined if the consumer put their scripts in the `head`. 
123-     const  isDisabled  =  ! this . _checksAreEnabled ( )  || 
124-       ( this . _sanityChecks  ===  false  ||  ! ( this . _sanityChecks  as  GranularSanityChecks ) . theme ) ; 
125- 
126-     if  ( isDisabled  ||  ! this . _document . body  ||  typeof  getComputedStyle  !==  'function' )  { 
128+     if  ( ! this . _checkIsEnabled ( 'theme' )  ||  ! this . _document . body  || 
129+         typeof  getComputedStyle  !==  'function' )  { 
127130      return ; 
128131    } 
129132
@@ -150,10 +153,7 @@ export class MatCommonModule {
150153
151154  /** Checks whether the material version matches the cdk version */ 
152155  private  _checkCdkVersionMatch ( ) : void { 
153-     const  isEnabled  =  this . _checksAreEnabled ( )  && 
154-       ( this . _sanityChecks  ===  true  ||  ( this . _sanityChecks  as  GranularSanityChecks ) . version ) ; 
155- 
156-     if  ( isEnabled  &&  VERSION . full  !==  CDK_VERSION . full )  { 
156+     if  ( this . _checkIsEnabled ( 'version' )  &&  VERSION . full  !==  CDK_VERSION . full )  { 
157157      console . warn ( 
158158          'The Angular Material version ('  +  VERSION . full  +  ') does not match '  + 
159159          'the Angular CDK version ('  +  CDK_VERSION . full  +  ').\n'  + 
0 commit comments