(iconName: string, iconEl: Icon)
| 83 | }; |
| 84 | |
| 85 | const 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 | |
| 108 | export const getName = ( |
| 109 | iconName: string | undefined, |
no test coverage detected
searching dependent graphs…