From 3fa10aa4ebf9ff7d443f8f2564dcaf9b63ce1fa8 Mon Sep 17 00:00:00 2001 From: ciaasteczkowy Date: Wed, 17 May 2023 17:46:26 +0700 Subject: [PATCH] fix(ButtonGroup/AvatarGroup): allow `v-for` (#173) Co-authored-by: Benjamin Canac --- src/runtime/components/elements/AvatarGroup.ts | 11 ++++++++--- src/runtime/components/elements/ButtonGroup.ts | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/runtime/components/elements/AvatarGroup.ts b/src/runtime/components/elements/AvatarGroup.ts index bc0826f0..06fed0d6 100644 --- a/src/runtime/components/elements/AvatarGroup.ts +++ b/src/runtime/components/elements/AvatarGroup.ts @@ -36,10 +36,15 @@ export default defineComponent({ const children = computed(() => { let children = slots.default?.() - // @ts-ignore-next - if (children.length && children[0].type.name === 'ContentSlot') { + if (children.length) { + if (typeof children[0].type === 'symbol') { + // @ts-ignore-next + children = children[0].children // @ts-ignore-next - children = children[0].ctx.slots.default?.() + } else if (children[0].type.name === 'ContentSlot') { + // @ts-ignore-next + children = children[0].ctx.slots.default?.() + } } return children }) diff --git a/src/runtime/components/elements/ButtonGroup.ts b/src/runtime/components/elements/ButtonGroup.ts index 5bb5b4b7..d822eaee 100644 --- a/src/runtime/components/elements/ButtonGroup.ts +++ b/src/runtime/components/elements/ButtonGroup.ts @@ -30,10 +30,15 @@ export default defineComponent({ const children = computed(() => { let children = slots.default?.() - // @ts-ignore-next - if (children.length && children[0].type.name === 'ContentSlot') { + if (children.length) { + if (typeof children[0].type === 'symbol') { + // @ts-ignore-next + children = children[0].children // @ts-ignore-next - children = children[0].ctx.slots.default?.() + } else if (children[0].type.name === 'ContentSlot') { + // @ts-ignore-next + children = children[0].ctx.slots.default?.() + } } return children })