Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to set <input type="checkbox" bind:group> value to an object literal with multiple members #14462

Closed
yamplum opened this issue Nov 28, 2024 · 3 comments · Fixed by Rich-Harris/esrap#14 or #14480
Labels

Comments

@yamplum
Copy link

yamplum commented Nov 28, 2024

Describe the bug

Setting the value prop of an <input type="checkbox"> element used in a bind:group setup to an object literal with multiple members fails to compile. Empty object literal {} or an object with at most one key seems to work. Objects in general seem to work as well, such as when wrapped in an IIFE.

Reproduction

https://svelte.dev/playground/74d3488e87e14e539fada023cd88109a?version=5.2.10

Logs

No response

System Info

System:
    OS: macOS 15.1.1
    CPU: (8) arm64 Apple M1
    Memory: 153.75 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 23.1.0 - /opt/homebrew/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 10.9.0 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 131.0.6778.86
    Safari: 18.1.1
  npmPackages:
    svelte: ^5.0.0 => 5.1.2

Severity

annoyance

@brunnerh
Copy link
Member

This generated function probably needs some parentheses:

$.bind_group(
	binding_group,
	[],
	input,
	() => {
-		{ index, value: $.get(value) };
+		({ index, value: $.get(value) });
		return $.get(values);
	},
	($$value) => $.set(values, $$value)
);

@paoloricciuti
Copy link
Member

I've opened a PR to esrap to fix this but we will need to update Rich-Harris/esrap#14

@Rich-Harris
Copy link
Member

auto-closed via the esrap PR but we should keep it open until #14480 is merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants