-
-
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
let-binding fails when multiple elements are assigned to the same slot #4135
Comments
Interesting, If you swap the elements of slot A, it expose the value. REPL But of course, the output will be different:
On the other hand, if you expose the variable 'a' to both slot="a" elements it produce the output you expected: REPL.
Continuing the test, if you create another element of slot="a" and don't expose the variable to that given slot, it will made the first element of slot="a" undefined again. REPL. Producing the next output:
It seems like, for all slot elements of the same type you need to expose all the variables. But if you expose the variables in the components itself, and not on the slot, it works as we expect. REPL.
|
Huh, to be honest, I'd expect assigning multiple elements to the same slot to fail at compile time unless the multiples were inside mutually exclusive conditionals. If the multiples were outside statically resolvable mutually exclusive conditionals I'd expect to see a runtime error. In your REPL's case I'm super surprised by the fact that the Oof. Slots are complicated |
If you want to assign multiple elements into the same slot, you could use <script>
import Nested from './Nested.svelte';
</script>
<Nested let:x>
<svelte:fragment slot="a" let:a>
<p>{a} {x}</p>
<p>{x}</p>
</svelte:fragment>
<svelte:fragment slot="b" let:b>
<p>{x}</p>
<p>{b} {x}</p>
</svelte:fragment>
</Nested> https://svelte.dev/repl/10435c582a1541caa0555037bc336440?version=3.35.0 |
Describe the bug
If two elements are assigned to the same slot,
let
bindings on the first element are syntactically accepted, but don't actually introduce any bindings.To Reproduce
https://svelte.dev/repl/193a784e481947979ee20f97a8fc8200?version=3.16.5
Expected behavior
The output should be:
but instead it's
Alternatively, a compiler error would be acceptable.
Severity
Low.
The text was updated successfully, but these errors were encountered: