Skip to content

Svelte 5: Index is undefined within a #each loop on a element with a transition #9421

@chainlist

Description

@chainlist

Describe the bug

Hello everyone,

I found a bug when using an #each...as... block with an animation on the element.

When looping through a collection and getting the index of the items while having a transition on the element returns an undefined index after the animation got triggered. But not always.

Reproduction

You can reproduce the issue on this REPL. The bug is not visible right away you have to trigger the animation by clicking on the buttons.

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAACn1T0W7bMAz8FU4bahvwkrXF9uA6AfaYb4jzoFnyRkyRDIkOGgj-94lWgqZBMfjBIH28O53oKAY0OohmH4WVRy0a8XMcRS3oPHIRTtqQTnVwk--504be40jbznaEx9F5gghBG92T8zDD4N0RijxXvLxDDVLpO8SavLQBCZ0tGGs0AZI-BtjAl0CSdLnnfkcRUDXwWAPbbKATuwSDx07UoJxNnUGakOjrW_jTHfzpDU5-ukc_36GfPyY_VHysi1nOic3uCwYWNRTklOO3NKY4LAH0zoaMTMBrVGUG3nKlqyDttdpdA1Da40mrcklklT-XCJstxOwbByiZd4WhzAYqeHiAT7jiogKvafI2u3_5YCRb4JH_TFxaHNjSmSs23a7fFsG2Ck_QGxnCpltWJ3Ri2ZD4Wcv-zyUlGYDmzNn-moicBWd7g_3fTSwrPtZiLGgqqZq3keZ2nXGZa81cM0snuaw7mVuZ9wEmOQ6uBoQlweqqbRDcRA2v4yZGUJOXvIBpu75_gzkJM3rFqzDDV9hZpV8biJjcGLx3kg3cPG2gs9ELbJWPfbkrhWE08px2yejXS7S_5ZhUf4y5XgjzePrjjk7hgFqJhpOfD_M_s5STGKwDAAA=

Logs

No log in the console

System Info

System:
    OS: Windows 11 10.0.22621
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700H
    Memory: 16.27 GB / 31.68 GB
  Binaries:
    Node: 18.13.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 8.19.3 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.3.1 - ~\AppData\Roaming\npm\pnpm.CMD
  Browsers:
    Edge: Chromium (119.0.2151.58)
    Internet Explorer: 11.0.22621.1

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions