Skip to content

Svelte 5: {#each expression as name (key)} behaves differently than Svelte 4 #11232

Closed
@qupig

Description

@qupig

Describe the bug

{#each expression as name (key)}...{/each}

The issue is that the behavior of key in the above syntax is different in Svelte 4 and 5.

It took a lot of time to lock in to this and make an intuitive minimal reproduction.

Strangely, somehow it couldn't be reproduced in the official Svelte5-REPL, so I had to use StackBlitz to provide an online preview.

You can see in the demo how the actual rendering of the component elements behaves differently when changing the order of the array elements.

Reproduction

StackBlitz-svelte-4.2.15

StackBlitz-svelte-5.0.0-next.108

Svelte5-REPL (Unable to reproduce)

svelte5.0.0-next.108.mp4

Logs

No response

System Info

svelte: 5.0.0-next.108

Severity

blocking an upgrade

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