Skip to content

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

Closed
@dooshiifox

Description

@dooshiifox

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions