Description
Is your feature request related to a problem? Please describe.
Event modifiers are long to type, and they could use shorter names or aliases, and in addition, it would be very helpful to have an additional self
modifier that is very common.
Describe the solution you'd like
I would like to have the next aliases (inspiration from vue) for the modifiers:
stop
as an alias for stopPropagation
and prevent
as an alias for preventDefault
.
In addition, I would like to have a self
modifier, that essentially checks that the clicked element is the one on which I added the event listener.
Describe alternatives you've considered
For the self
modifier:
<script context="module">
let el;
function closeMenu(e) {
if (e.target !== el) return;
...do stuff...
}
</script>
<div bind:this={el} on:click|stopPropagation={doSomething}>
...
</div>
How important is this feature to you?
Events are at the very core of every reactive web app, I think that making it a little bit easier to use, is very important. In addition, It shouldn't be hard to do.