Skip to content

each loop sends an undefined value if using bind and keyΒ #14203

@olafurw

Description

@olafurw

Describe the bug

Looping through items like this in Svelte 5 (in non runes mode)

{#each items as item, idx (item.id)}
	<Component bind:item />
{/each}

Will send undefined into Component when in Svelte 4 it worked.

Reproduction

Undefined value in Svelte 5
https://svelte.dev/playground/63e98bd6fa774e1f9e2fccba1ada7a05?version=5.1.12

But is defined in Svelte 4
https://svelte.dev/playground/63e98bd6fa774e1f9e2fccba1ada7a05?version=4.2.19

Removing bind or key or index will fix it. But all 3 will give you undefined

Logs

No response

System Info

System:
    OS: Linux 6.8 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
    CPU: (16) x64 12th Gen Intel(R) Core(TM) i7-1260P
    Memory: 7.24 GB / 30.96 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 18.20.2 - ~/.nvm/versions/node/v18.20.2/bin/node
    npm: 10.8.3 - ~/.nvm/versions/node/v18.20.2/bin/npm
    bun: 1.1.7 - ~/.bun/bin/bun
  Browsers:
    Chrome: 130.0.6723.91
  npmPackages:
    svelte: ^5.1.9 => 5.1.9

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions