-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Infinite loop while binding an array to a child component #4325
Comments
Svelte detects when you add the same attribute twice: <Component value="1" value="2" /> Will correctly give you the error: Attributes need to be unique However <Component value="1" bind:value /> Does not give the same error, although I think it should considering it's somehow also a duplicate attribute. |
Yeah, I agree that |
* disallow matching attributes/shorthands/bindings (#4325) * add tests * update changelog
In 3.18.2, it's now a compiler error to have any two of |
I think that this should be allowed though.
|
I don't know what |
I used this construct in an autocomplete dropdown component, where I wanted to keep the query and the selected value separated. |
We use this to set an initial value on an input, but at the same time keep it up to date. How would we change that to work with these changes? |
You would set the bound-to value to an initial value.
|
So
|
The docs are maybe a bit ambiguous, it could indeed be interpreted as bind reversing the flow, while in reality it allows data to flow both ways. |
* disallow matching attributes/shorthands/bindings (sveltejs#4325) * add tests * update changelog
* disallow matching attributes/shorthands/bindings (sveltejs#4325) * add tests * update changelog
Describe the bug
I have two components :
Cpn.svelte
and a consumer :
this consumer has a "bug" : it injects {items} and creates a binding with items. However svelte doesn't output any warning, and the generated code has an infinite loop when the component is rendered.
It "worked" in svelte 3.12
The bug is not really in svelte but in my code, however it's a "hard to debug" case, because chrome/firefox just crash every time the component is shown (and it worked in 3.12).
To Reproduce
I can't provide a REPL because this bug crashes the app.
Expected behavior
The generated code doesn't have an infinite loop/svelte emits an error.
Information about your Svelte project:
The text was updated successfully, but these errors were encountered: