2
0
mirror of https://github.com/iconify/iconify.git synced 2024-11-09 14:50:56 +00:00

Web component: do not attempt to load icon without prefix from API

This commit is contained in:
Vjacheslav Trushkin 2022-05-14 13:04:07 +03:00
parent 6911d07b55
commit 08974d4aa8
3 changed files with 20 additions and 3 deletions

View File

@ -23,7 +23,8 @@ export function parseIconValue(
onload: IconOnLoadCallback
): CurrentIconData {
// Check if icon name is valid
const name = typeof value === 'string' ? stringToIcon(value, true) : null;
const name =
typeof value === 'string' ? stringToIcon(value, true, true) : null;
if (!name) {
// Test for serialised object
const data = testIconObject(value);
@ -35,7 +36,9 @@ export function parseIconValue(
// Valid icon name: check if data is available
const data = getIconData(name);
if (data !== void 0) {
// Icon data exists or icon has no prefix. Do not load icon from API if icon has no prefix
if (data !== void 0 || !name.prefix) {
return {
value,
name,

View File

@ -44,6 +44,10 @@ import type {
IconifyRenderMode,
} from './attributes/types';
import { defineIconifyIcon } from './component';
import type {
IconifyIconHTMLElement,
IconifyIconHTMLElementClass,
} from './component';
import { exportFunctions } from './functions';
/**
@ -85,7 +89,12 @@ export { IconifyIconBuildResult };
export { IconifyBrowserCacheType };
// Component types
export { IconifyIconAttributes, IconifyRenderMode };
export {
IconifyIconAttributes,
IconifyRenderMode,
IconifyIconHTMLElement,
IconifyIconHTMLElementClass,
};
/**
* Create exported data: either component instance or functions

View File

@ -52,6 +52,11 @@ describe('Testing parseIconValue without API', () => {
});
expect(result).toEqual({
value,
name: {
provider: '',
prefix: '',
name: value,
},
});
});
});