Skip to content

Svelte 5: immutable compiler affects the #each block different than Svelte 4 #9521

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

Closed
birkskyum opened this issue Nov 17, 2023 · 0 comments · Fixed by #10537
Closed

Svelte 5: immutable compiler affects the #each block different than Svelte 4 #9521

birkskyum opened this issue Nov 17, 2023 · 0 comments · Fixed by #10537
Assignees

Comments

@birkskyum
Copy link

birkskyum commented Nov 17, 2023

Describe the bug

The normal each block syntax doesn't appear to function properly in Svelte 5, with the immutable compiler.

Reproduction

Svelte 5 Link
Svelte 4 Link

<svelte:options immutable />
<script>

let items = [{id:1,value: "test"}]
const update = () => {
  const clone = items.slice();
  clone[0].value += " !!!";
  items = clone;
}

</script>

<button on:click={update} >Update</button>

<!-- Doesn't update in Svelte 5, but does in Svelte 4 -->
<ul>
  {#each items as item (item.id)}
    <li>{item.value}</li>
  {/each}
</ul>

<!-- Updates -->
<ul>
  <li>{items[0].value}</li>
</ul>

Logs

No response

System Info

System:
    OS: macOS 14.1.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 175.50 MB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node
    npm: 9.8.1 - ~/.nvm/versions/node/v18.18.2/bin/npm
    pnpm: 8.10.5 - ~/Library/pnpm/pnpm
    bun: 1.0.11 - ~/.bun/bin/bun
    Watchman: 2023.09.18.00 - /opt/homebrew/bin/watchman
  Browsers:
    Brave Browser: 119.1.60.114
    Chrome: 119.0.6045.159
    Safari: 17.1
@birkskyum birkskyum changed the title immutable compiler affects the #each block different in svelte 4/5 Svelte 5: immutable compiler affects the #each block different than Svelte 4 Nov 18, 2023
@benmccann benmccann added this to the 5.0 milestone Nov 24, 2023
@trueadm trueadm self-assigned this Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants