Re: [whatwg/dom] "inner invoke" of event listener with "once" doesn't mark listener as "removed" (Issue #1323)

I'm not sure I entirely follow.

1. The first event is dispatched.
2. We clone the target's listener list and run each listener.
3. Before the listener that dispatches the second event is run, we remove it from the target's listener list.
4. We run the listener that dispatches the second event.
5. The second event is dispatched.
6. We clone the target's listener list and run each listener.

Why would the listener that dispatches the second event still be in target's listener list in step 6?

---

(The console warning step of https://dom.spec.whatwg.org/#remove-an-event-listener does make it somewhat attractive to invoke that instead.)

---

Aside: the source code for this step currently reads:
```
   <li><p>If <var>listener</var>'s <a for="event listener">once</a> is true, then
   <a for=list>remove an event listener</a> given <var>event</var>'s {{Event/currentTarget}} and
   <var>listener</var> from 
   attribute value's <a for=EventTarget>event listener list</a>.
   <!-- Do this before invocation to avoid reentrancy issues. No need to set removed to true since
        each listener in listeners is run once anyway. -->
```
I wonder if this is actually wrong what else might be wrong here.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/1323#issuecomment-2482260865
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/issues/1323/2482260865@github.com>

Received on Monday, 18 November 2024 08:29:20 UTC