Skip to content

Commit 3ab8448

Browse files
committed
refactor: simplify props definition in SvgIcon component and optimize child node replacement
1 parent 0fbcd28 commit 3ab8448

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/components/SvgIcon.vue

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,17 @@ const svgElMap = computedAsync(
55
);
66
</script>
77
<script setup lang="ts">
8-
const props = withDefaults(
9-
defineProps<{
10-
name: string;
11-
}>(),
12-
{},
13-
);
8+
const props = defineProps<{
9+
name: string;
10+
}>();
1411
1512
const svgEl = computed(() => svgElMap.value[props.name]);
1613
const actualEl = shallowRef<SVGSVGElement>();
1714
watchEffect(() => {
1815
const s = svgEl.value;
1916
const a = actualEl.value;
2017
if (!s || !a) return;
21-
a.replaceChildren(...Array.from(s.cloneNode(true).childNodes));
18+
a.replaceChildren(...s.cloneNode(true).childNodes);
2219
});
2320
</script>
2421
<template>

tsconfig.app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"skipLibCheck": false,
77
"composite": true,
88
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
9-
"lib": ["ESNext"],
9+
"lib": ["ESNext", "DOM", "DOM.Iterable"],
1010
"baseUrl": ".",
1111
"erasableSyntaxOnly": true,
1212
"noUncheckedIndexedAccess": false,

0 commit comments

Comments
 (0)