Skip to content
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

onDestroy seems to hold a reference to an incorrect prop #15420

Closed
jkbz64 opened this issue Mar 3, 2025 · 2 comments
Closed

onDestroy seems to hold a reference to an incorrect prop #15420

jkbz64 opened this issue Mar 3, 2025 · 2 comments

Comments

@jkbz64
Copy link

jkbz64 commented Mar 3, 2025

Describe the bug

After splicing an array that is rendered with {#each} block, the onDestroy has a wrong reference to the prop, this can be observed in my reproduction - after clicking on remove we are removing an element from the middle of an array and onDestroy is called with x that corresponds to the last element of the array instead (?). After going out of flushSync last element's field is now undefined because of onDestroy (or null if onDestroy is not used).

Reproduction

https://svelte.dev/playground/1d048ad074c64ca586a46d3d8daecd83?version=5.20.5

Logs

We are splicing in the middle, why onDestroy has a reference to the last value?

Image

System Info

System:
    OS: Linux 6.12 Fedora Linux Asahi Remix 41 (Forty One)
    CPU: (8) arm64 unknown
    Memory: 5.61 GB / 31.12 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 18.20.4 - ~/.n/bin/node
    Yarn: 1.22.21 - ~/.n/bin/yarn
    npm: 10.7.0 - ~/.n/bin/npm
    pnpm: 10.2.1 - ~/.local/share/pnpm/pnpm
    bun: 1.2.4 - ~/.n/bin/bun

Severity

annoyance

@jkbz64 jkbz64 changed the title bind:this does not reattach unkeyed elements onDestroy seems to hold a reference to an incorrect prop Mar 3, 2025
@Prinzhorn
Copy link
Contributor

Probably #14725

@paoloricciuti
Copy link
Member

Yup, closing this as a duplicate

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

No branches or pull requests

3 participants