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

Implementation of delegated events #357

Open
titoBouzout opened this issue Sep 25, 2024 · 1 comment
Open

Implementation of delegated events #357

titoBouzout opened this issue Sep 25, 2024 · 1 comment

Comments

@titoBouzout
Copy link
Contributor

titoBouzout commented Sep 25, 2024

Delegated events are a nice concept that improves performance of event handlers[citation needed], but that unintentionally introduce some edge cases. There are reasons to believe that we could keep delegated events as intended by dom-expressions, without messing unrelated expectations.

Opening this issue to investigate what could be done about it, and if the intention would be achievable.

@titoBouzout
Copy link
Contributor Author

An idea that came to mind the other day,

For Portals, it may be possible to add a real event listener, prevent default, and redispatch the event in the $host. That way the event will bubble the component tree, but things like preventDefault will still work. In pseudocode on the lines of :

<Portal on:click={(e)=>{
  e.preventDefault()
  $portalHost.dispatchEvent(new Event('click'))
}}/>

What this is trying, is to make match the behaviour of delegated events with native events. I think having delegated events behaving differently to native events it's a regretful mistake, but at the same time bubbling to a different parent is not something supported by the platform, so maybe this idea I came with could? alleviate the problem

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

1 participant