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

Unclear > in Svelte 5 migration guide #13799

Closed
adamshand opened this issue Oct 22, 2024 · 2 comments · Fixed by #13800
Closed

Unclear > in Svelte 5 migration guide #13799

adamshand opened this issue Oct 22, 2024 · 2 comments · Fixed by #13800

Comments

@adamshand
Copy link

Describe the bug

In "why we did this?" under "multiple event handlers" there are a bunch of >.

I assume they are typos, but if not their meaning is unclear to me.

It was always possible to use component callback props, but because you had to listen to dom events using on:, it made sense to use createEventDispatcher for component events due to ❓> syntactical consiscency. Now that we have event attributes (onclick), it’s the other way around: Callback props are now the more sensible thing to do.

The removal of event modifiers is arguably one of the changes that seems like a step back for those who’ve liked the shorthand syntax of event modifiers. Given that they are not used that ❓> frequently, we traded a smaller surface area for more explicitness. Modifiers also were inconsistent, because most of them were only useable on Dom elements.

Multiple listeners for the same event are also no longer possible, but it was something of an anti-pattern anyway, since it impedes readability: if there are many attributes, it becomes ❓> harder to spot that there are two handlers unless they are right next to each other. It also implies that the two handlers are independent, when in fact something like event.❓> stopImmediatePropagation() inside one would prevent two from being called.

Reproduction

.

Logs

.

System Info

.

Severity

annoyance

@adamshand
Copy link
Author

Also consiscency should be consistency.

@brunnerh
Copy link
Member

Probably a side effect of moving lines around, those "why we did this?" blocks are formatted as Markdown blockquotes so each line starts with a >.

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

Successfully merging a pull request may close this issue.

2 participants