- From: Claudia Meadows <notifications@github.com>
- Date: Tue, 09 Mar 2021 13:05:54 -0800
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Tuesday, 9 March 2021 21:06:06 UTC
The code is trying to emulate that. The idea is you might use it like this: ``` combine( {onclick(e) { if (eventShouldntBeHandled(e)) e.stopImmediatePropagation() }}, {onclick(e) { /* do something with the event */ }}, ) // Or a more real-world scenario const ignoreIf = (name, cond) => ({[`on${name}`]: e => { if (cond(e)) e.stopImmediatePropagation() }}) combine( ignoreIf("click", e => eventShouldntBeHandled(e)), {onclick(e) { /* do something with the event */ }}, ) ``` As most virtual DOM frameworks don't let you register multiple listeners per event, this would make it very easy to wrap. Also, from a framework implementation perspective, most add only one per event for performance and do all their work in that one listener (it avoids a significant amount of overhead as the engine can optimize for how it's called), so it'd be nice to be able to do that without also having to add a weak set in the middle. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/958#issuecomment-794453456
Received on Tuesday, 9 March 2021 21:06:06 UTC