<slot /> used as a passthrough outlet inside an SFC template (e.g. DialogTrigger.vue's <Primitive as-child><slot /></Primitive>) resolves through Vue's renderSlot() helper, which always wraps the forwarded content in a Fragment vnode -- even when there's exactly one real child. Slot was cloning that inert Fragment wrapper instead of the real child, so attrs merged onto asChild-forwarded elements (data-slot, aria-*, the click handler) silently vanished. Found via manual Storybook verification: the Dialog trigger rendered but never opened the dialog on click. Unwrap single-child Fragments before merging/cloning, and add a regression test through a real SFC fixture (a raw h()-based test doesn't reproduce this, since it never goes through renderSlot()).
11 lines
261 B
Vue
11 lines
261 B
Vue
<script setup lang="ts">
|
|
import { Primitive } from '@/lib/primitive'
|
|
|
|
defineProps<{ asChild?: boolean }>()
|
|
</script>
|
|
|
|
<template>
|
|
<Primitive as="button" :as-child="asChild" type="button" data-slot="passthrough-wrapper">
|
|
<slot />
|
|
</Primitive>
|
|
</template>
|