Describe the bug
The scope of this
changes when attaching class method handlers differently to on*
.
That is,
<button onclick={() => counter.increment()}>
vs
<button onclick={counter.increment}>
Reproduction
Open the console with both examples to see the output.
Working Example (1)
Attaching and calling from an arrow function.
<button onclick={() => counter.increment()}>
Outputs the Counter {#count: {...}}
class instance.
Broken (?) Example (2)
Attaching directly as class method.
<button onclick={counter.increment}>
Clicking the button produces the scope of the <button>
element.

This breaks reactivity, so this.count = this.count + 1
is happening on the <button>
element instead of the class instance.
Logs
Logs are listed above under <<Reproduction>>.
System Info
n/a -- running on https://svelte-5-preview.vercel.app/ version `5.0.0-next.26`
Severity
annoyance