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

Read-only bindings require getter function, even though it should be irrelevant #15549

Open
brunnerh opened this issue Mar 19, 2025 · 4 comments

Comments

@brunnerh
Copy link
Member

Describe the bug

E.g. you will need something like

<input bind:this={() => {}, input => { ... }} />

Maybe bind:this={null, input => { ... }} or some other flavor should be possible?

Reproduction

<script>
	let value = $state();
	$inspect(value);
</script>

<input value="test" bind:this={null, e => value = e.value} />

Playground

Logs

System Info

REPL

Severity

annoyance

@paoloricciuti
Copy link
Member

I think it's doable...but it's really needed if the bind is unidirectional? Who use this instead of just bind:this?

@brunnerh
Copy link
Member Author

brunnerh commented Mar 19, 2025

Possibly useful in snippets.

{@render thing(element => ...)}
{#snippet thing(cb)}
   <input bind:this={null, cb}>
{/snippet}

Otherwise you need an object with a property definition.

@dummdidumm
Copy link
Member

In that case why not <input oninput={cb} /> instead?

Honestly not sure if we need to enhance this for such an edge case (and it's only a few characters)

@paoloricciuti
Copy link
Member

It's bind:this not bind:value...but yeah feels like a super edge case...however it could be just a quick fix so we might just as well doing it.

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

No branches or pull requests

3 participants