events
events copied to clipboard
Implementation of stopImmediatePropagation
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?
Here's the code change
for (var i = 0; i < len; ++i)
if( ReflectApply(listeners[i], this, args) === 'stopImmediatePropagation' ) break;
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.