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

Method _updateSvgIcon

src/material/icon/icon.ts:451–478  ·  view source on GitHub ↗

Sets a new SVG icon with a particular name.

(rawName: string | undefined)

Source from the content-addressed store, hash-verified

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

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