Nychthemeron/packages/library/tests/fixtures/SlotPassthrough.vue
Matthew L McPeak 8c830438d5 fix: unwrap Fragment vnodes in Slot before cloning
<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()).
2026-07-13 18:37:50 -04:00

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>