mirror of
https://github.com/iconify/iconify.git
synced 2024-11-09 23:00:56 +00:00
Fix listIcons in SVG framework and update few comments
This commit is contained in:
parent
85ae70961b
commit
d31bd5fca4
@ -62,6 +62,16 @@ describe('Testing Iconify object', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('Check listIcons', () => {
|
||||
expect(Iconify.listIcons('', prefix)).to.be.eql([
|
||||
prefix + ':account-box',
|
||||
prefix + ':account-cash',
|
||||
prefix + ':account',
|
||||
prefix + ':home',
|
||||
prefix + ':id-test',
|
||||
]);
|
||||
});
|
||||
|
||||
it('Get SVG node', () => {
|
||||
const node = Iconify.renderSVG(prefix + ':account', {
|
||||
inline: true,
|
||||
|
@ -170,6 +170,7 @@ export interface IconifyGlobal {
|
||||
*/
|
||||
addCollection: (data: IconifyJSON, provider?: string) => boolean;
|
||||
|
||||
/* Render icons */
|
||||
/**
|
||||
* Render icons
|
||||
*/
|
||||
@ -192,7 +193,7 @@ export interface IconifyGlobal {
|
||||
) => IconifyIconBuildResult | null;
|
||||
|
||||
/**
|
||||
* Replace IDs in icon body, should be used when parsing buildIcon() result
|
||||
* Replace IDs in icon body, should be used when parsing renderIcon() result
|
||||
*/
|
||||
replaceIDs: (body: string, prefix?: string | (() => string)) => string;
|
||||
|
||||
@ -202,6 +203,7 @@ export interface IconifyGlobal {
|
||||
*/
|
||||
scan: (root?: HTMLElement) => void;
|
||||
|
||||
/* Observer */
|
||||
/**
|
||||
* Add root node
|
||||
*/
|
||||
@ -212,7 +214,6 @@ export interface IconifyGlobal {
|
||||
*/
|
||||
stopObserving: (root: HTMLElement) => void;
|
||||
|
||||
/* Observer */
|
||||
/**
|
||||
* Pause observer
|
||||
*/
|
||||
@ -242,7 +243,7 @@ export const IconifyCommon: IconifyGlobal = {
|
||||
|
||||
// List icons
|
||||
listIcons: (provider?: string, prefix?: string) => {
|
||||
let icons = [];
|
||||
let allIcons = [];
|
||||
|
||||
// Get providers
|
||||
let providers: string[];
|
||||
@ -256,7 +257,7 @@ export const IconifyCommon: IconifyGlobal = {
|
||||
providers.forEach((provider) => {
|
||||
let prefixes: string[];
|
||||
|
||||
if (typeof prefix === 'string') {
|
||||
if (typeof provider === 'string' && typeof prefix === 'string') {
|
||||
prefixes = [prefix];
|
||||
} else {
|
||||
prefixes = listStoredPrefixes(provider);
|
||||
@ -264,18 +265,18 @@ export const IconifyCommon: IconifyGlobal = {
|
||||
|
||||
prefixes.forEach((prefix) => {
|
||||
const storage = getStorage(provider, prefix);
|
||||
let icons = Object.keys(storage.icons).map(
|
||||
const icons = Object.keys(storage.icons).map(
|
||||
(name) =>
|
||||
(provider !== '' ? '@' + provider + ':' : '') +
|
||||
prefix +
|
||||
':' +
|
||||
name
|
||||
);
|
||||
icons = icons.concat(icons);
|
||||
allIcons = allIcons.concat(icons);
|
||||
});
|
||||
});
|
||||
|
||||
return icons;
|
||||
return allIcons;
|
||||
},
|
||||
|
||||
// Add icon
|
||||
|
Loading…
Reference in New Issue
Block a user