I know I can automatically forward a component event by just on:myEvent.
I know I can manually forward a component event (CustomEvent) by
on:myEvent={(event) => {
doSomethingWith(event);
createEventDispatcher()('myEvent', event.detail);
}}
I know I can automatically forward a DOM event by just on:click.
However, I don't how how to manually forward a DOM event, as in
on:click={(event) => {
doSomethingWith(event);
// WHAT DO I DO HERE?
}}
There's not a way to manually emit a DOM event from a component. What the forwarding on:click does internally is to directly call all of the component event handlers.
One thing you could do is to attach two handlers for the event on the element, one two forward the event and one to handle it. <button on:click={doSomethingWith} on:click>. Which one is positioned first in the arguments is the one that will happen first, if that's important for your application.
Ah... I didn't know I can put multiple handlers on the same event. Thanks.