-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Open
Description
Describe the bug
As per this documentation, I am trying to create a wrapper around a <select> element, but unlike the examples, I want to forward the bindable-ness of the values to the inner component.
However, when I try to bind to any attributes in ...rest, I get the warning: Cannot use 'bind:' with this property. It is declared as non-bindable inside the component. To mark a property as bindable: 'let { value = $bindable() } = $props()'ts(2322).
When I try to write ...rest = $bindable(), I get a number of errors:
Unexpected token https://svelte.dev/e/js_parse_errorA rest element cannot have an initializer.ts(1186)
How can I forward binding for all bindable properties for the original HTML element?
For now, I am stuck with forwarding all properties that I intend to use, which is a very frustrating user experience.
Reproduction
<script lang="ts">
import type { HTMLSelectAttributes } from 'svelte/elements';
let { children, ...rest = $bindable() }: HTMLSelectAttributes = $props();
</script>
<!-- Don't think this is the right syntax either -->
<select bind:{...rest}>
{@render children?.()}
</select>Logs
System Info
System:
OS: Linux 6.12 Fedora Linux 41 (Workstation Edition)
CPU: (12) x64 Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
Memory: 50.22 GB / 62.41 GB
Container: Yes
Shell: 5.9 - /usr/bin/zsh
Binaries:
Node: 22.12.0 - /run/user/1000/fnm_multishells/45856_1738052668661/bin/node
npm: 10.9.0 - /run/user/1000/fnm_multishells/45856_1738052668661/bin/npm
bun: 1.1.34 - ~/.bun/bin/bun
Browsers:
Chrome: 132.0.6834.110
npmPackages:
svelte: ^5.6.0 => 5.19.3Severity
annoyance
Metadata
Metadata
Assignees
Labels
No labels