- From: Andreas Kling <notifications@github.com>
- Date: Mon, 18 Nov 2024 00:42:11 -0800
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Monday, 18 November 2024 08:42:15 UTC
Here's a simplified example:
```html
<script>
var type = "foo";
var target = document.createElement("div");
function listener1() {
console.log("Listener 1");
console.log("Before inner dispatch");
target.dispatchEvent(new Event(type));
console.log("After inner dispatch");
}
function listener2() {
console.log("Listener 2");
}
target.addEventListener(type, listener1, { once: true });
target.addEventListener(type, listener2, { once: true });
console.log("Before outer dispatch");
target.dispatchEvent(new Event(type));
console.log("After outer dispatch");
</script>
```
When we begin the outer dispatch, the listeners are cloned. `listener2` is in the cloned list.
When we begin the inner dispatch, the listeners are cloned. `listener2` is in this cloned list as well.
After the inner dispatch invokes `listener2`, it's removed from the target, but it's still in the outer dispatch's cloned list.
Does that make sense, or am I missing something here? :)
--
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/1323#issuecomment-2482288674
You are receiving this because you are subscribed to this thread.
Message ID: <whatwg/dom/issues/1323/2482288674@github.com>
Received on Monday, 18 November 2024 08:42:15 UTC