|
6 | 6 | * found in the LICENSE file at https://angular.io/license |
7 | 7 | */ |
8 | 8 |
|
9 | | -import {coerceBooleanProperty} from '@angular/cdk/coercion'; |
10 | | -import {DOCUMENT} from '@angular/common'; |
| 9 | +import {take} from 'rxjs/operators'; |
11 | 10 | import { |
12 | | - AfterViewChecked, |
13 | 11 | Attribute, |
14 | 12 | ChangeDetectionStrategy, |
15 | 13 | Component, |
16 | 14 | ElementRef, |
17 | | - ErrorHandler, |
18 | | - inject, |
19 | | - Inject, |
20 | | - InjectionToken, |
21 | 15 | Input, |
22 | 16 | OnChanges, |
23 | | - OnDestroy, |
24 | 17 | OnInit, |
25 | | - Optional, |
26 | 18 | SimpleChanges, |
27 | 19 | ViewEncapsulation, |
| 20 | + Optional, |
| 21 | + InjectionToken, |
| 22 | + inject, |
| 23 | + Inject, |
| 24 | + OnDestroy, |
| 25 | + AfterViewChecked, |
28 | 26 | } from '@angular/core'; |
| 27 | +import {DOCUMENT} from '@angular/common'; |
29 | 28 | import {CanColor, CanColorCtor, mixinColor} from '@angular/material/core'; |
30 | | -import {take} from 'rxjs/operators'; |
31 | | - |
| 29 | +import {coerceBooleanProperty} from '@angular/cdk/coercion'; |
32 | 30 | import {MatIconRegistry} from './icon-registry'; |
33 | 31 |
|
34 | 32 |
|
@@ -180,15 +178,14 @@ export class MatIcon extends _MatIconMixinBase implements OnChanges, OnInit, Aft |
180 | 178 | private _elementsWithExternalReferences?: Map<Element, {name: string, value: string}[]>; |
181 | 179 |
|
182 | 180 | constructor( |
183 | | - elementRef: ElementRef<HTMLElement>, private _iconRegistry: MatIconRegistry, |
| 181 | + elementRef: ElementRef<HTMLElement>, |
| 182 | + private _iconRegistry: MatIconRegistry, |
184 | 183 | @Attribute('aria-hidden') ariaHidden: string, |
185 | 184 | /** |
186 | 185 | * @deprecated `location` parameter to be made required. |
187 | 186 | * @breaking-change 8.0.0 |
188 | 187 | */ |
189 | | - @Optional() @Inject(MAT_ICON_LOCATION) private _location?: MatIconLocation, |
190 | | - // @breaking-change 9.0.0 _errorHandler parameter to be made required |
191 | | - @Optional() private readonly _errorHandler?: ErrorHandler) { |
| 188 | + @Optional() @Inject(MAT_ICON_LOCATION) private _location?: MatIconLocation) { |
192 | 189 | super(elementRef); |
193 | 190 |
|
194 | 191 | // If the user has not explicitly set aria-hidden, mark the icon as hidden, as this is |
@@ -231,17 +228,10 @@ export class MatIcon extends _MatIconMixinBase implements OnChanges, OnInit, Aft |
231 | 228 | if (this.svgIcon) { |
232 | 229 | const [namespace, iconName] = this._splitIconName(this.svgIcon); |
233 | 230 |
|
234 | | - this._iconRegistry.getNamedSvgIcon(iconName, namespace) |
235 | | - .pipe(take(1)) |
236 | | - .subscribe(svg => this._setSvgElement(svg), (err: Error) => { |
237 | | - const errorMessage = `Error retrieving icon ${namespace}:${iconName}! ${err.message}`; |
238 | | - // @breaking-change 9.0.0 _errorHandler parameter to be made required. |
239 | | - if (this._errorHandler) { |
240 | | - this._errorHandler.handleError(new Error(errorMessage)); |
241 | | - } else { |
242 | | - console.error(errorMessage); |
243 | | - } |
244 | | - }); |
| 231 | + this._iconRegistry.getNamedSvgIcon(iconName, namespace).pipe(take(1)).subscribe( |
| 232 | + svg => this._setSvgElement(svg), |
| 233 | + (err: Error) => console.log(`Error retrieving icon: ${err.message}`) |
| 234 | + ); |
245 | 235 | } else if (svgIconChanges.previousValue) { |
246 | 236 | this._clearSvgElement(); |
247 | 237 | } |
|
0 commit comments