Skip to content
This repository was archived by the owner on Jul 1, 2021. It is now read-only.

Allow removeEventListener in listener callback #57

Merged
merged 1 commit into from
Jun 30, 2021
Merged

Allow removeEventListener in listener callback #57

merged 1 commit into from
Jun 30, 2021

Conversation

Kal-Aster
Copy link
Contributor

Having a callback with a call to removeEventListener on the same EventTarget causes the listeners list to change hence to skip some listener.

Here an example

const { EventTarget, Event } = require("basichtml");

const e = new EventTarget();
e.addEventListener("test", function test() {
  e.removeEventListener("test", test);
  console.log("test 1");
});
e.addEventListener("test", function test() {
  // this never runs because of the `removeEventListener` in previous call
  console.log("test 2");
});
e.addEventListener("test", function test() {
  // this runs because the iterator kept going
  console.log("test 3");
});
e.dispatchEvent(new Event("test"));

@WebReflection
Copy link
Owner

The change is small and sensible enough, this module has been deprecated and (I think) archived? I suggest you to move to LinkeDOM ASAP, as I’m not maintaining this module these days, and quirks are known and many.

@WebReflection
Copy link
Owner

actually, I haven't deprecated this ... will do soon.

@WebReflection WebReflection merged commit 50e8131 into WebReflection:master Jun 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants