MCPcopy
hub / github.com/ionic-team/ionicons / getNamedUrl

Function getNamedUrl

src/components/icon/utils.ts:85–106  ·  view source on GitHub ↗
(iconName: string, iconEl: Icon)

Source from the content-addressed store, hash-verified

83};
84
85const getNamedUrl = (iconName: string, iconEl: Icon) => {
86 const url = getIconMap().get(iconName);
87 if (url) {
88 return url;
89 }
90 try {
91 return getAssetPath(`svg/${iconName}.svg`);
92 } catch (e) {
93 console.log('e', e);
94 /**
95 * In the custom elements build version of ionicons, referencing an icon
96 * by name will throw an invalid URL error because the asset path is not defined.
97 * This catches that error and logs something that is more developer-friendly.
98 * We also include a reference to the ion-icon element so developers can
99 * figure out which instance of ion-icon needs to be updated.
100 */
101 console.warn(
102 `[Ionicons Warning]: Could not load icon with name "${iconName}". Ensure that the icon is registered using addIcons or that the icon SVG data is passed directly to the icon component.`,
103 iconEl,
104 );
105 }
106};
107
108export const getName = (
109 iconName: string | undefined,

Callers 1

getUrlFunction · 0.85

Calls 1

getIconMapFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…