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

Bindings don't receive context from let variables #3140

Closed
Rich-Harris opened this issue Jun 30, 2019 · 3 comments · Fixed by #3171
Closed

Bindings don't receive context from let variables #3140

Rich-Harris opened this issue Jun 30, 2019 · 3 comments · Fixed by #3171
Labels

Comments

@Rich-Harris
Copy link
Member

Via this Stack Overflow question.

Using a let variable in a binding doesn't work — the binding function isn't passed the relevant context, it seems: https://svelte.dev/repl/278fe8b586f443889632803dcff8bcca?version=3.6.1

Rich-Harris added a commit that referenced this issue Jul 6, 2019
Pass context used in bindings down to slots
@Eh2406
Copy link

Eh2406 commented Dec 25, 2019

This issue was closed, but the example has the same error on the current version 3.16.7. Should I open a new issue?

@Conduitry
Copy link
Member

What issue are you seeing? The bindings in https://svelte.dev/repl/278fe8b586f443889632803dcff8bcca?version=3.16.7 seem to be working fine for me.

@Eh2406
Copy link

Eh2406 commented Dec 25, 2019

You are correct. Sorry for the noize. I must have gotten my links mixed up. That example is not triggering an error.

I just got myself very confused while reading the error message on my code. I thought it was referring to the let in export let thing;. The only thing that came up googling the message was this discussion. It took me sometime to notice the : and figure out that it was referring to the let: in let:index. My code had:

<FancyList items={items} let:item>
	<input type=text bind:value={item.x}>
	<input type=text bind:value={item.y}>
</FancyList>

Once I saw the difference I was able to use the trick (item -> items[index]) from this issue to fix it.

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

Successfully merging a pull request may close this issue.

3 participants