@@ -175,7 +175,8 @@ export class MatIconRegistry implements OnDestroy {
175
175
options ?: IconOptions ) : this {
176
176
const cleanLiteral = this . _sanitizer . sanitize ( SecurityContext . HTML , literal ) ;
177
177
178
- if ( ! cleanLiteral && ( typeof ngDevMode === 'undefined' || ngDevMode ) ) {
178
+ // TODO: add an ngDevMode check
179
+ if ( ! cleanLiteral ) {
179
180
throw getMatIconFailedToSanitizeLiteralError ( literal ) ;
180
181
}
181
182
@@ -217,7 +218,7 @@ export class MatIconRegistry implements OnDestroy {
217
218
options ?: IconOptions ) : this {
218
219
const cleanLiteral = this . _sanitizer . sanitize ( SecurityContext . HTML , literal ) ;
219
220
220
- if ( ! cleanLiteral && ( typeof ngDevMode === 'undefined' || ngDevMode ) ) {
221
+ if ( ! cleanLiteral ) {
221
222
throw getMatIconFailedToSanitizeLiteralError ( literal ) ;
222
223
}
223
224
@@ -381,11 +382,12 @@ export class MatIconRegistry implements OnDestroy {
381
382
return forkJoin ( iconSetFetchRequests ) . pipe ( map ( ( ) => {
382
383
const foundIcon = this . _extractIconWithNameFromAnySet ( name , iconSetConfigs ) ;
383
384
384
- if ( ! foundIcon && ( typeof ngDevMode === 'undefined' || ngDevMode ) ) {
385
+ // TODO: add an ngDevMode check
386
+ if ( ! foundIcon ) {
385
387
throw getMatIconNameNotFoundError ( name ) ;
386
388
}
387
389
388
- return foundIcon ! ;
390
+ return foundIcon ;
389
391
} ) ) ;
390
392
}
391
393
@@ -491,7 +493,8 @@ export class MatIconRegistry implements OnDestroy {
491
493
div . innerHTML = str ;
492
494
const svg = div . querySelector ( 'svg' ) as SVGElement ;
493
495
494
- if ( ! svg && ( typeof ngDevMode === 'undefined' || ngDevMode ) ) {
496
+ // TODO: add an ngDevMode check
497
+ if ( ! svg ) {
495
498
throw Error ( '<svg> tag not found' ) ;
496
499
}
497
500
@@ -552,31 +555,33 @@ export class MatIconRegistry implements OnDestroy {
552
555
throw getMatIconNoHttpProviderError ( ) ;
553
556
}
554
557
555
- if ( safeUrl == null && ( typeof ngDevMode === 'undefined' || ngDevMode ) ) {
558
+ // TODO: add an ngDevMode check
559
+ if ( safeUrl == null ) {
556
560
throw Error ( `Cannot fetch icon from URL "${ safeUrl } ".` ) ;
557
561
}
558
562
559
563
const url = this . _sanitizer . sanitize ( SecurityContext . RESOURCE_URL , safeUrl ) ;
560
564
561
- if ( ! url && ( typeof ngDevMode === 'undefined' || ngDevMode ) ) {
562
- throw getMatIconFailedToSanitizeUrlError ( safeUrl ! ) ;
565
+ // TODO: add an ngDevMode check
566
+ if ( ! url ) {
567
+ throw getMatIconFailedToSanitizeUrlError ( safeUrl ) ;
563
568
}
564
569
565
570
// Store in-progress fetches to avoid sending a duplicate request for a URL when there is
566
571
// already a request in progress for that URL. It's necessary to call share() on the
567
572
// Observable returned by http.get() so that multiple subscribers don't cause multiple XHRs.
568
- const inProgressFetch = this . _inProgressUrlFetches . get ( url ! ) ;
573
+ const inProgressFetch = this . _inProgressUrlFetches . get ( url ) ;
569
574
570
575
if ( inProgressFetch ) {
571
576
return inProgressFetch ;
572
577
}
573
578
574
- const req = this . _httpClient . get ( url ! , { responseType : 'text' , withCredentials} ) . pipe (
575
- finalize ( ( ) => this . _inProgressUrlFetches . delete ( url ! ) ) ,
579
+ const req = this . _httpClient . get ( url , { responseType : 'text' , withCredentials} ) . pipe (
580
+ finalize ( ( ) => this . _inProgressUrlFetches . delete ( url ) ) ,
576
581
share ( ) ,
577
582
) ;
578
583
579
- this . _inProgressUrlFetches . set ( url ! , req ) ;
584
+ this . _inProgressUrlFetches . set ( url , req ) ;
580
585
return req ;
581
586
}
582
587
0 commit comments