mirror of
https://github.com/iconify/iconify.git
synced 2025-01-07 15:44:05 +00:00
Web component: do not attempt to load icon without prefix from API
This commit is contained in:
parent
6911d07b55
commit
08974d4aa8
@ -23,7 +23,8 @@ export function parseIconValue(
|
|||||||
onload: IconOnLoadCallback
|
onload: IconOnLoadCallback
|
||||||
): CurrentIconData {
|
): CurrentIconData {
|
||||||
// Check if icon name is valid
|
// 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) {
|
if (!name) {
|
||||||
// Test for serialised object
|
// Test for serialised object
|
||||||
const data = testIconObject(value);
|
const data = testIconObject(value);
|
||||||
@ -35,7 +36,9 @@ export function parseIconValue(
|
|||||||
|
|
||||||
// Valid icon name: check if data is available
|
// Valid icon name: check if data is available
|
||||||
const data = getIconData(name);
|
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 {
|
return {
|
||||||
value,
|
value,
|
||||||
name,
|
name,
|
||||||
|
@ -44,6 +44,10 @@ import type {
|
|||||||
IconifyRenderMode,
|
IconifyRenderMode,
|
||||||
} from './attributes/types';
|
} from './attributes/types';
|
||||||
import { defineIconifyIcon } from './component';
|
import { defineIconifyIcon } from './component';
|
||||||
|
import type {
|
||||||
|
IconifyIconHTMLElement,
|
||||||
|
IconifyIconHTMLElementClass,
|
||||||
|
} from './component';
|
||||||
import { exportFunctions } from './functions';
|
import { exportFunctions } from './functions';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -85,7 +89,12 @@ export { IconifyIconBuildResult };
|
|||||||
export { IconifyBrowserCacheType };
|
export { IconifyBrowserCacheType };
|
||||||
|
|
||||||
// Component types
|
// Component types
|
||||||
export { IconifyIconAttributes, IconifyRenderMode };
|
export {
|
||||||
|
IconifyIconAttributes,
|
||||||
|
IconifyRenderMode,
|
||||||
|
IconifyIconHTMLElement,
|
||||||
|
IconifyIconHTMLElementClass,
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create exported data: either component instance or functions
|
* Create exported data: either component instance or functions
|
||||||
|
@ -52,6 +52,11 @@ describe('Testing parseIconValue without API', () => {
|
|||||||
});
|
});
|
||||||
expect(result).toEqual({
|
expect(result).toEqual({
|
||||||
value,
|
value,
|
||||||
|
name: {
|
||||||
|
provider: '',
|
||||||
|
prefix: '',
|
||||||
|
name: value,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user