Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event support #11

Open
janosh opened this issue Nov 3, 2020 · 1 comment
Open

Event support #11

janosh opened this issue Nov 3, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@janosh
Copy link

janosh commented Nov 3, 2020

It would be cool if SVG components supported events. Right now, something like this doesn't work:

<script>
import Icon from './my-icon.svg'
</script>

<Icon on:click={() => console.log(`hi`)} />

Instead, you need to wrap the SVG in a DOM element, e.g.

<span on:click={() => console.log(`hi`)}>
  <Icon />
</span>

Anything this package could do to enable the first version? Still learning how the Svelte compiler works so this might be a dumb question.

@MKRhere
Copy link
Member

MKRhere commented Aug 13, 2021

I'm sure you understand the Svelte limitation that kept me from implementing this, and the issue you linked from reflects this. There's simply no way to lazily bind to all events / pass event listeners as props without defining all of them. There is now an rfc that might solve our problem:
https://github.com/Sxxov/rfcs/blob/master/text/0000-spread-binding.md

I shall continue to leave this issue open until we can do this correctly in Svelte :) Thanks for the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants