events icon indicating copy to clipboard operation
events copied to clipboard

Implementation of stopImmediatePropagation

Open boblund opened this issue 1 year ago • 2 comments

I implemented stopImmediatePropagation with a really simple change. In the emit prototype loop that executes the listeners I check the ReflectApply return for the string 'stopImmediatePropagation'. To stop a event propagation the event handler then returns 'stopImmediatePropagation'.

Will this break something? Is there interest in adding this?

boblund avatar Nov 04 '24 17:11 boblund

Here's the code change

    for (var i = 0; i < len; ++i)
      if( ReflectApply(listeners[i], this, args) === 'stopImmediatePropagation' ) break;

boblund avatar Nov 04 '24 17:11 boblund

stopImmediatePropagation is part of the EventTarget API which is not supported by this module at the moment. Custom extensions outside of the Node.js API are out of scope. If we add this it should be part of the EventTarget API.

goto-bus-stop avatar Nov 12 '24 09:11 goto-bus-stop