@yhwh-script/event-bux 1.0.7 → 1.0.8

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 +7 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export const name = "eventbux"; // The module name, can be made globally available via the window object, which should be on top.
1
+ export const name = "eventbus"; // The module name, can be made globally available via the window object, which should be on top.
2
2
  const listeners = new WeakMap(); // WeakMap to store listeners per object. Keep it private unless you know what you do.
3
3
  // Should auto-cleanup listeners when object is GC'd (TODO Test!)
4
4
  // This module implements EventTarget.
@@ -36,8 +36,12 @@ export function removeEventListener(type, listener, context = undefined) {
36
36
  }
37
37
 
38
38
  export function dispatchEvent(event, context = undefined) { // TODO check if context == event.target, if yes, remove context? What if CustomEvent is used?
39
- if (!context) { // observe!
40
- context = event.target;
39
+ if (!context) {
40
+ if (event instanceof CustomEvent) {
41
+ context = event.detail.target;
42
+ } else {
43
+ context = event.target;
44
+ }
41
45
  }
42
46
  if (context && listeners.has(context)) {
43
47
  const contextListeners = listeners.get(context);
package/package.json CHANGED
@@ -22,5 +22,5 @@
22
22
  "url": "git+https://github.com/yhwh-script/event-bux.git"
23
23
  },
24
24
  "type": "module",
25
- "version": "1.0.7"
25
+ "version": "1.0.8"
26
26
  }