sveltejs / svelte

Cybernetically enhanced web apps
https://svelte.dev
MIT License
76.8k stars 3.98k forks source link

Array access not supported in the `use` or `transition` directives #11467

Open fcrozatier opened 2 weeks ago

fcrozatier commented 2 weeks ago

Describe the bug

This syntax

{#each assembly.speakers as speaker, i}
    <button use:assembly.speakers[i].action>speaker {i}</button>
{/each}

gets compiled down to

$.action(button, ($$node) => assembly["speakers[i]"].action($$node));

so the array access doesn't work.

But all the other variations do work so it's a bit confusing / seems like a bug.

Same thing for transitions

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAE5WS3W6DMAyFX8XLJg2kQu9bQNsz7LLpRUrdNRokKDarKsS7TwFCW3XazwWI-Dg-n206cdAVklhtOmFUjWIlXptGLASfG3-gT6wYxUKQbV3pIxmVTjdcSCNZ1411DN1B7bGHg7M1yOnKkp0ypFlbI8XaJ_unrBQRvDWoPtBBN4RZlT4LcohiyIsQlVxaQ7bCtLLvkRRHLUU8Sr0048fFA3LwEIPRJI9er0RY76ozhLo0mhPk8ESsGKPNNl5PnsO7dKgYA6THyosbKAaaRYOn0E8UhwqS-agpDVZp09Ixmk5xSHHIrTOh1KWzmX9wUoF_tArtRCNyUNMb5kHMlpdFmewhSWBvkcwzw8m6D5AmSQppukdU5XF2mZFBUSBbgB6wsl3LbA20hKu7_I3eptMetfleviyrCOPrdJ8tx7KeZelZ-sDrMelfhN3LNLPwQ_2AeXPh5j_6Bf5-FnPbf-9wmP20lv_3ee0-SVfDD5G_00CSFGIharvXB417sWLXYr_tvwCr6_BOHQQAAA==

Logs

No response

System Info

preview

Severity

annoyance