mirror of
https://github.com/iconify/iconify.git
synced 2025-01-05 23:10:40 +00:00
fix: create empty objects from null in utils
This commit is contained in:
parent
1f32c18768
commit
425905b7be
@ -1,4 +1,8 @@
|
|||||||
import type { ExtendedIconifyIcon, IconifyJSON } from '@iconify/types';
|
import type {
|
||||||
|
ExtendedIconifyIcon,
|
||||||
|
IconifyAliases,
|
||||||
|
IconifyJSON,
|
||||||
|
} from '@iconify/types';
|
||||||
import { mergeIconData } from '../icon/merge';
|
import { mergeIconData } from '../icon/merge';
|
||||||
import { getIconsTree } from './tree';
|
import { getIconsTree } from './tree';
|
||||||
|
|
||||||
@ -11,7 +15,7 @@ export function internalGetIconData(
|
|||||||
tree: string[]
|
tree: string[]
|
||||||
): ExtendedIconifyIcon {
|
): ExtendedIconifyIcon {
|
||||||
const icons = data.icons;
|
const icons = data.icons;
|
||||||
const aliases = data.aliases || {};
|
const aliases = data.aliases || (Object.create(null) as IconifyAliases);
|
||||||
|
|
||||||
let currentProps = {} as ExtendedIconifyIcon;
|
let currentProps = {} as ExtendedIconifyIcon;
|
||||||
|
|
||||||
|
@ -25,7 +25,8 @@ export function getIcons(
|
|||||||
};
|
};
|
||||||
|
|
||||||
const sourceIcons = data.icons;
|
const sourceIcons = data.icons;
|
||||||
const sourceAliases = data.aliases || {};
|
const sourceAliases =
|
||||||
|
data.aliases || (Object.create(null) as IconifyAliases);
|
||||||
|
|
||||||
// Add lastModified
|
// Add lastModified
|
||||||
if (data.lastModified) {
|
if (data.lastModified) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { IconifyJSON } from '@iconify/types';
|
import type { IconifyAliases, IconifyJSON } from '@iconify/types';
|
||||||
|
|
||||||
// Parent icons, first is direct parent, last is icon. Does not include self
|
// Parent icons, first is direct parent, last is icon. Does not include self
|
||||||
export type ParentIconsList = string[];
|
export type ParentIconsList = string[];
|
||||||
@ -16,7 +16,7 @@ export function getIconsTree(
|
|||||||
names?: string[]
|
names?: string[]
|
||||||
): ParentIconsTree {
|
): ParentIconsTree {
|
||||||
const icons = data.icons;
|
const icons = data.icons;
|
||||||
const aliases = data.aliases || {};
|
const aliases = data.aliases || (Object.create(null) as IconifyAliases);
|
||||||
|
|
||||||
const resolved = Object.create(null) as ParentIconsTree;
|
const resolved = Object.create(null) as ParentIconsTree;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { IconifyJSON } from '@iconify/types';
|
import type { IconifyAliases, IconifyJSON } from '@iconify/types';
|
||||||
import { matchIconName } from '../icon/name';
|
import { matchIconName } from '../icon/name';
|
||||||
import {
|
import {
|
||||||
defaultIconDimensions,
|
defaultIconDimensions,
|
||||||
@ -75,7 +75,7 @@ export function quicklyValidateIconSet(obj: unknown): IconifyJSON | null {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check all aliases
|
// Check all aliases
|
||||||
const aliases = data.aliases || {};
|
const aliases = data.aliases || (Object.create(null) as IconifyAliases);
|
||||||
for (const name in aliases) {
|
for (const name in aliases) {
|
||||||
const icon = aliases[name];
|
const icon = aliases[name];
|
||||||
const parent = icon.parent;
|
const parent = icon.parent;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import type {
|
import type {
|
||||||
ExtendedIconifyIcon,
|
ExtendedIconifyIcon,
|
||||||
|
IconifyAliases,
|
||||||
IconifyJSON,
|
IconifyJSON,
|
||||||
IconifyOptional,
|
IconifyOptional,
|
||||||
} from '@iconify/types';
|
} from '@iconify/types';
|
||||||
@ -135,7 +136,7 @@ export function validateIconSet(
|
|||||||
// Validate all icons and aliases
|
// Validate all icons and aliases
|
||||||
const tree = getIconsTree(data);
|
const tree = getIconsTree(data);
|
||||||
const icons = data.icons;
|
const icons = data.icons;
|
||||||
const aliases = data.aliases || {};
|
const aliases = data.aliases || (Object.create(null) as IconifyAliases);
|
||||||
for (const name in tree) {
|
for (const name in tree) {
|
||||||
const treeItem = tree[name];
|
const treeItem = tree[name];
|
||||||
const isAlias = !icons[name];
|
const isAlias = !icons[name];
|
||||||
|
@ -41,7 +41,7 @@ export function commonObjectProps<T extends Record<string, unknown>>(
|
|||||||
item: unknown,
|
item: unknown,
|
||||||
reference: T
|
reference: T
|
||||||
): Partial<T> {
|
): Partial<T> {
|
||||||
const result = {} as T;
|
const result = Object.create(null) as T;
|
||||||
for (const key in reference) {
|
for (const key in reference) {
|
||||||
if (key in (item as T)) {
|
if (key in (item as T)) {
|
||||||
result[key] = (item as T)[key];
|
result[key] = (item as T)[key];
|
||||||
|
Loading…
Reference in New Issue
Block a user