Re: [whatwg/dom] Could a property be exposed so I can observe `.stopImmediatePropagation()`? (#958)

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