@vanillaspa/event-bus 1.4.1 → 1.4.3
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.
- package/index.js +3 -1
- 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)
|
|
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