-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
Describe the problem
I would like for the functionality of event modifiers previously available before svelte 5 for example 'click', 'once' and 'preventDefault' (shown below) to be readily available in svelte 5.
<button on:click|once|preventDefault={handler}>...</button>
Describe the proposed solution
In the preview documentation it suggests creating functions to replace event modifiers.
So the following:
<button on:once|preventDefault={handler}>...</button>
would be rewritten as:
<button onclick={once(preventDefault(handler))}>...</button>
In my opinion, it would be nice if these functions were available from the svelte library itself rather than having to write them independently. This would bring parity between svelte 4 in and svelte 5 for this feature and help minimise work needed for migration.
I understand the addition of these functions needs to be considered against the trade-off of additional bloat to the library, especially as these are relatively quick and simple functions to write (though ensuring the typing is correct adds some difficulty in my experience).
I would be happy to put in a PR for the change if it is deemed a worthwhile addition.
Importance
nice to have