MCPcopy Create free account
hub / github.com/angular/components / _updateSvgIcon

Method _updateSvgIcon

src/material/icon/icon.ts:445–472  ·  view source on GitHub ↗

Sets a new SVG icon with a particular name.

(rawName: string | undefined)

Source from the content-addressed store, hash-verified

443
444 /** Sets a new SVG icon with a particular name. */
445 private _updateSvgIcon(rawName: string | undefined) {
446 this._svgNamespace = null;
447 this._svgName = null;
448 this._currentIconFetch.unsubscribe();
449
450 if (rawName) {
451 const [namespace, iconName] = this._splitIconName(rawName);
452
453 if (namespace) {
454 this._svgNamespace = namespace;
455 }
456
457 if (iconName) {
458 this._svgName = iconName;
459 }
460
461 this._currentIconFetch = this._iconRegistry
462 .getNamedSvgIcon(iconName, namespace)
463 .pipe(take(1))
464 .subscribe(
465 svg => this._setSvgElement(svg),
466 (err: Error) => {
467 const errorMessage = `Error retrieving icon ${namespace}:${iconName}! ${err.message}`;
468 this._errorHandler.handleError(new Error(errorMessage));
469 },
470 );
471 }
472 }
473}

Callers 1

svgIconMethod · 0.95

Calls 4

_splitIconNameMethod · 0.95
_setSvgElementMethod · 0.95
getNamedSvgIconMethod · 0.45
handleErrorMethod · 0.45

Tested by

no test coverage detected