wgge 2.0.37 → 2.0.38
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.
|
@@ -6,7 +6,7 @@ export default class EventManager {
|
|
|
6
6
|
|
|
7
7
|
addEventListener(eventName, eventHandler) {
|
|
8
8
|
if (!this.handlers.has(eventName)) {
|
|
9
|
-
this.handlers.
|
|
9
|
+
this.handlers.set(eventName, [eventHandler]);
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
12
|
/*
|
|
@@ -25,10 +25,14 @@ export default class EventManager {
|
|
|
25
25
|
}
|
|
26
26
|
const handlers = this.handlers.get(eventName);
|
|
27
27
|
const index = handlers.indexOf(eventHandler);
|
|
28
|
+
if (index === 0 && handlers.length === 0) {
|
|
29
|
+
this.handlers.delete(eventName);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
28
32
|
if (index >= 0) {
|
|
29
33
|
handlers.splice(index, 1);
|
|
30
34
|
} else {
|
|
31
|
-
|
|
35
|
+
console.warn(`Event listener '${eventName}' cannot be removed - not found.`);
|
|
32
36
|
}
|
|
33
37
|
}
|
|
34
38
|
|