|
1 | | -import { |
2 | | - NgModule, |
3 | | - Directive, |
4 | | - Inject, |
5 | | - Optional, |
6 | | - isDevMode, |
7 | | - ElementRef, |
8 | | - InjectionToken, |
9 | | -} from '@angular/core'; |
10 | | -import {DOCUMENT} from '@angular/platform-browser'; |
| 1 | +import {NgModule, Directive, Inject, Optional, ElementRef, InjectionToken} from '@angular/core'; |
11 | 2 |
|
12 | 3 | export const MATERIAL_COMPATIBILITY_MODE = new InjectionToken<boolean>('md-compatibility-mode'); |
13 | 4 |
|
14 | | -/** Injection token that configures whether the Material sanity checks are enabled. */ |
15 | | -export const MATERIAL_SANITY_CHECKS = new InjectionToken<boolean>('md-sanity-checks'); |
16 | | - |
17 | 5 | /** |
18 | 6 | * Returns an exception to be thrown if the consumer has used |
19 | 7 | * an invalid Material prefix on a component. |
@@ -183,54 +171,8 @@ export class MdPrefixRejector { |
183 | 171 | @NgModule({ |
184 | 172 | declarations: [MatPrefixRejector, MdPrefixRejector], |
185 | 173 | exports: [MatPrefixRejector, MdPrefixRejector], |
186 | | - providers: [{ |
187 | | - provide: MATERIAL_SANITY_CHECKS, useValue: true, |
188 | | - }], |
189 | 174 | }) |
190 | | -export class CompatibilityModule { |
191 | | - /** Whether we've done the global sanity checks (e.g. a theme is loaded, there is a doctype). */ |
192 | | - private _hasDoneGlobalChecks = false; |
193 | | - |
194 | | - constructor( |
195 | | - @Optional() @Inject(DOCUMENT) private _document: any, |
196 | | - @Optional() @Inject(MATERIAL_SANITY_CHECKS) _sanityChecksEnabled: boolean) { |
197 | | - |
198 | | - if (_sanityChecksEnabled && !this._hasDoneGlobalChecks && _document && isDevMode()) { |
199 | | - // Delay running the check to allow more time for the user's styles to load. |
200 | | - this._checkDoctype(); |
201 | | - this._checkTheme(); |
202 | | - this._hasDoneGlobalChecks = true; |
203 | | - } |
204 | | - } |
205 | | - |
206 | | - private _checkDoctype(): void { |
207 | | - if (!this._document.doctype) { |
208 | | - console.warn( |
209 | | - 'Current document does not have a doctype. This may cause ' + |
210 | | - 'some Angular Material components not to behave as expected.' |
211 | | - ); |
212 | | - } |
213 | | - } |
214 | | - |
215 | | - private _checkTheme(): void { |
216 | | - if (typeof getComputedStyle === 'function') { |
217 | | - const testElement = this._document.createElement('div'); |
218 | | - |
219 | | - testElement.classList.add('mat-theme-loaded-marker'); |
220 | | - this._document.body.appendChild(testElement); |
221 | | - |
222 | | - if (getComputedStyle(testElement).display !== 'none') { |
223 | | - console.warn( |
224 | | - 'Could not find Angular Material core theme. Most Material ' + |
225 | | - 'components may not work as expected. For more info refer ' + |
226 | | - 'to the theming guide: https://material.angular.io/guide/theming' |
227 | | - ); |
228 | | - } |
229 | | - |
230 | | - this._document.body.removeChild(testElement); |
231 | | - } |
232 | | - } |
233 | | -} |
| 175 | +export class CompatibilityModule {} |
234 | 176 |
|
235 | 177 |
|
236 | 178 | /** |
|
0 commit comments