Skip to content

Dispatching events from custom elements #2611

@colinbate

Description

@colinbate

Svelte v3.1.0
Firefox Developer Edition 67

I realize that the documentation around custom elements in v3 isn't complete, but I've been poking around the code and I'm not sure I can see a way to do what I was expecting.

Basically, I'd like to use the dispatch method returned from createEventDispatcher() to send native DOM events (element.dispatchEvent) when in a custom element situation. I'd be fine if it was something that required an option be sent to createEventDispatcher. I could probably do something with Actions or bind:this, but that feels awkward.

Essentially I would like my compiled custom element to be used in a context where it doesn't know it is coming from Svelte and therefore will be using standard DOM interaction. This doesn't feel like an unusual situation.

I've created a gist that contains all of the relevant files. If this isn't sufficient, let me know.
https://gist.github.com/colinbate/3f56197c41b2b0fc3f4e700cf7121528

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions