@vanillaspa/event-bus 1.4.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +3 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -12,7 +12,9 @@ export function addEventListener(type, listener, context) {
12
12
  byType.get(type).push(listener);
13
13
 
14
14
  if (!typeIndex.has(type)) typeIndex.set(type, new Set());
15
- typeIndex.get(type).add(new WeakRef(context));
15
+ const refs = typeIndex.get(type);
16
+ const alreadyRegistered = [...refs].some(ref => ref.deref() === context);
17
+ if (!alreadyRegistered) refs.add(new WeakRef(context));
16
18
  }
17
19
 
18
20
  export function removeEventListener(type, listener, context) {
package/package.json CHANGED
@@ -27,5 +27,5 @@
27
27
  "url": "git+https://github.com/vanillaspa/event-bus.git"
28
28
  },
29
29
  "type": "module",
30
- "version": "1.4.1"
30
+ "version": "1.4.2"
31
31
  }