Skip to content

Commit e00e7a1

Browse files
committed
revert(mat-icon): this reverts two files from commit 79e4d28
* These checks caused failures in pantheon where icons were not loading
1 parent f0c7a25 commit e00e7a1

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

src/material/icon/icon-registry.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ export class MatIconRegistry implements OnDestroy {
175175
options?: IconOptions): this {
176176
const cleanLiteral = this._sanitizer.sanitize(SecurityContext.HTML, literal);
177177

178-
if (!cleanLiteral && (typeof ngDevMode === 'undefined' || ngDevMode)) {
178+
// TODO: add an ngDevMode check
179+
if (!cleanLiteral) {
179180
throw getMatIconFailedToSanitizeLiteralError(literal);
180181
}
181182

@@ -217,7 +218,7 @@ export class MatIconRegistry implements OnDestroy {
217218
options?: IconOptions): this {
218219
const cleanLiteral = this._sanitizer.sanitize(SecurityContext.HTML, literal);
219220

220-
if (!cleanLiteral && (typeof ngDevMode === 'undefined' || ngDevMode)) {
221+
if (!cleanLiteral) {
221222
throw getMatIconFailedToSanitizeLiteralError(literal);
222223
}
223224

@@ -381,11 +382,12 @@ export class MatIconRegistry implements OnDestroy {
381382
return forkJoin(iconSetFetchRequests).pipe(map(() => {
382383
const foundIcon = this._extractIconWithNameFromAnySet(name, iconSetConfigs);
383384

384-
if (!foundIcon && (typeof ngDevMode === 'undefined' || ngDevMode)) {
385+
// TODO: add an ngDevMode check
386+
if (!foundIcon) {
385387
throw getMatIconNameNotFoundError(name);
386388
}
387389

388-
return foundIcon!;
390+
return foundIcon;
389391
}));
390392
}
391393

@@ -491,7 +493,8 @@ export class MatIconRegistry implements OnDestroy {
491493
div.innerHTML = str;
492494
const svg = div.querySelector('svg') as SVGElement;
493495

494-
if (!svg && (typeof ngDevMode === 'undefined' || ngDevMode)) {
496+
// TODO: add an ngDevMode check
497+
if (!svg) {
495498
throw Error('<svg> tag not found');
496499
}
497500

@@ -552,31 +555,33 @@ export class MatIconRegistry implements OnDestroy {
552555
throw getMatIconNoHttpProviderError();
553556
}
554557

555-
if (safeUrl == null && (typeof ngDevMode === 'undefined' || ngDevMode)) {
558+
// TODO: add an ngDevMode check
559+
if (safeUrl == null) {
556560
throw Error(`Cannot fetch icon from URL "${safeUrl}".`);
557561
}
558562

559563
const url = this._sanitizer.sanitize(SecurityContext.RESOURCE_URL, safeUrl);
560564

561-
if (!url && (typeof ngDevMode === 'undefined' || ngDevMode)) {
562-
throw getMatIconFailedToSanitizeUrlError(safeUrl!);
565+
// TODO: add an ngDevMode check
566+
if (!url) {
567+
throw getMatIconFailedToSanitizeUrlError(safeUrl);
563568
}
564569

565570
// Store in-progress fetches to avoid sending a duplicate request for a URL when there is
566571
// already a request in progress for that URL. It's necessary to call share() on the
567572
// 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);
569574

570575
if (inProgressFetch) {
571576
return inProgressFetch;
572577
}
573578

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)),
576581
share(),
577582
);
578583

579-
this._inProgressUrlFetches.set(url!, req);
584+
this._inProgressUrlFetches.set(url, req);
580585
return req;
581586
}
582587

src/material/icon/icon.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,7 @@ export class MatIcon extends _MatIconMixinBase implements OnChanges, OnInit, Aft
222222
switch (parts.length) {
223223
case 1: return ['', parts[0]]; // Use default namespace.
224224
case 2: return <[string, string]>parts;
225-
default:
226-
if (typeof ngDevMode === 'undefined' || ngDevMode) {
227-
throw Error(`Invalid icon name: "${iconName}"`);
228-
}
229-
return ['', ''];
225+
default: throw Error(`Invalid icon name: "${iconName}"`); // TODO: add an ngDevMode check
230226
}
231227
}
232228

0 commit comments

Comments
 (0)