-
I want to create a thin wrapper around some html element, but can't pass the <script lang="ts">
import type { HTMLAttributes } from "svelte/elements";
const { children, ...props }: HTMLAttributes<HTMLButtonElement> = $props();
</script>
<!-- Doesn't work (also invalid html) -->
<button {...props} {children} />
<!-- Doesn't work -->
<button {...props} {children}></button>
<!-- Doesn't work (a little unexpected) -->
<button {...props}>{children}</button>
<!-- Works, but requires additional check -->
<button {...props}>
{#if children}
{@render children()}
{/if}
</button> |
Beta Was this translation helpful? Give feedback.
Answered by
brunnerh
Sep 20, 2024
Replies: 1 comment
-
This: <button {...props}>{@render children?.()}</button> |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
x0k
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This: