Skip to content

Svelte 5: Event handlers break if a prop is placed after it if spread props exist #11284

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
dooshiifox opened this issue Apr 22, 2024 · 1 comment · Fixed by #11291
Closed
Milestone

Comments

@dooshiifox
Copy link

Describe the bug

If you add an event handler to an element that has spread props, placing another prop after the event handler causes a runtime error. On FireFox, this is EventTarget.addEventListener: Argument 2 is not an object.. Looking with the debugger, it seems to read the value of the wrong prop for adding the event handler. For example, in the repro, it tries to add "hello" as an event handler. Error is thrown from this line
Additionally, some events such as onclick or onkeydown don't cause this error.

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAA22QTW6EMAyFr5J6NSO10C66YQBpTtBKs2y6oGAgUv6UmJFQlLs3ZtRdd_b3_J4tJ5iVxgjNVwI7GIQGrt7DM9DuuYl31ISlj24LI5M2jkF5EnqwSyeBooReWkmjs5FEdAY_g_PxI9xKSauyi-hEyhdp2_ph5XHbKus3YmOkXWNJ8sM0lemXoJaVGvFavQc0F_GHNc6Fvh1UAhtTVVX_7cssOvujt9ClE55F14vETFJdHxcK7RY1ihUDPjgf7zRWhZ8krLgPTxLOrOUjzexHcsea1o731335inGTmhVO0FDYMH_nXwmS7vhQAQAA

Logs

No response

System Info

System:
    OS: Linux 6.6 NixOS 24.05 (Uakari) 24.05 (Uakari)
    CPU: (32) x64 13th Gen Intel(R) Core(TM) i9-13900HX
    Memory: 17.88 GB / 31.20 GB
    Container: Yes
    Shell: 5.2.26 - /run/current-system/sw/bin/bash
  Binaries:
    Node: 21.6.2 - /etc/profiles/per-user/dooshii/bin/node
    npm: 10.2.4 - /etc/profiles/per-user/dooshii/bin/npm
    pnpm: 8.15.3 - /etc/profiles/per-user/dooshii/bin/pnpm
  Browsers:
    Chromium: 122.0.6261.94
  npmPackages:
    svelte: 5.0.0-next.110 => 5.0.0-next.110

Severity

blocking an upgrade

@dummdidumm
Copy link
Member

Sounds like a var problem and we need to use let instead

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.

2 participants