[whatwg/dom] What happens if a 'once' eventListener dispatches a similar event? (#265)

What happens if a 'once' eventListener dispatches a similar event?

Code example:
`
var listenerCallCount = 0;
function listenerFunction()
{
    ++listenerCallCount;

    if (listenerCallCount == 1)
        document.body.dispatchEvent(new Event('test'));
}

document.body.addEventListener('test', listenerFunction, { 'once': true });
document.body.dispatchEvent(new Event('test'));
`

Relevant spec section:
https://dom.spec.whatwg.org/#concept-event-listener-inner-invoke

Based on the specification, it seems to me that the event handler would get executed twice despite being marked as 'once'? This is because we set the listener's removed flag to true *after* calling its handlerEvent().

Maybe the 'removed' flag should be set before calling handleEvent() in this case? Or is there something else in the spec that I missed and would prevent the listener to be executed twice in this case?

---
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/265

Received on Monday, 6 June 2016 19:07:22 UTC