Skip to content

addEventListener, object with a handleEvent() method support. #8196

Open
@tanangular

Description

@tanangular

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
event object

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    PRs welcomewe're not going to spend any time on this, but we'll accept pull requests

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions