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

Shorthand for propagating events #638

Closed
Rich-Harris opened this issue Jun 13, 2017 · 2 comments
Closed

Shorthand for propagating events #638

Rich-Harris opened this issue Jun 13, 2017 · 2 comments

Comments

@Rich-Harris
Copy link
Member

This has come up once or twice — since component events don't propagate (unlike DOM events), if you want to listen to an event coming from a deeply nested component you have to propagate the event manually, like so:

<IntermediateComponent on:foo='fire("foo",event)'/>

I don't think we should automatically bubble events, since that's a potential source of confusion and would mean adding annoying extra code to every component that had nested components. But we could make it a bit less burdensome to manually propagate events with a shorthand syntax:

<IntermediateComponent on:foo/>
@stalkerg
Copy link
Contributor

It's a good idea! But also I want to see shorthand syntax for preventDefault(). Like:

<a href="" on:default:click="set({svelte: 'perfect'})">link</a>

@Rich-Harris
Copy link
Member Author

Added in 1.27

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

No branches or pull requests

2 participants