You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Svelte compiler seems to work with listener objects via handleEvent(), but it produce different results when referencing by object name and "this" including to reactive ui.
Describe the proposed solution
svelte compiler should support addEventListener object with handleEvent()
Alternatives considered
svelte compiler should support addEventListener object with handleEvent()
Importance
nice to have
The text was updated successfully, but these errors were encountered:
it produce different results when referencing by object name and "this" including to reactive ui
Are you referring to adding an event like this?
on:click={listenerObj.myhandleEvent}
Then that has nothing to do with Svelte. If you reference a function like that, this will not be bound; that is just how JS works. Which is why you are supposed to use an anonymous function if you want this to be bound to the object the function is defined on:
Describe the problem
I'm not sure this is a bug or the framework's intention.
According to the DOM API specification document
addEventListener(type, listener)
listener could be an object that has a handleEvent() method.

Ref: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
I tried writing the following code in the svelte REPL:
Svelte REPL: https://svelte.dev/repl/538e3dbe765947a9b0a04a88cb050c6a?version=3.55.1
Svelte compiler seems to work with listener objects via handleEvent(), but it produce different results when referencing by object name and "this" including to reactive ui.
Describe the proposed solution
svelte compiler should support addEventListener object with handleEvent()
Alternatives considered
svelte compiler should support addEventListener object with handleEvent()
Importance
nice to have
The text was updated successfully, but these errors were encountered: