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

Cannot bind an object property to a component variable in #each if property name is "value" #4445

Closed
pushkine opened this issue Feb 22, 2020 · 1 comment · Fixed by #4452
Closed
Labels

Comments

@pushkine
Copy link
Contributor

pushkine commented Feb 22, 2020

<script>
...
const arr = [{ value: '' }]
</script>

{#each arr as { value }}
     <MyComponent bind:myVariable={value} />
{/each}

generates the following :

function mycomponent_myVariable_binding(value, value, each_value, each_index) {
	each_value[each_index].value = value;
	$$invalidate(0, arr);
}

the first argument is hardcoded to be "value" which makes it impossible to bind it to a property named the same way as the second argument, and although never used, the latter will always be named according to the target property

https://svelte.dev/repl/5527404b82fa4d83a07fecd9c03128df?version=3.18.2

@pushkine pushkine changed the title Cannot bind a $store object property to a component variable in #each if property name is "value" Cannot bind an object property to a component variable in #each if property name is "value" Feb 22, 2020
@Conduitry Conduitry added the bug label Feb 23, 2020
Conduitry added a commit to Conduitry/svelte that referenced this issue Feb 23, 2020
Conduitry added a commit to Conduitry/svelte that referenced this issue Feb 23, 2020
@Conduitry
Copy link
Member

Variable name clash fixed in 3.19.1 - https://svelte.dev/repl/5527404b82fa4d83a07fecd9c03128df?version=3.19.1

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.

2 participants