neo.mjs 4.0.34 → 4.0.37

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "4.0.34",
3
+ "version": "4.0.37",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -753,9 +753,7 @@ class Base extends CoreBase {
753
753
  * @protected
754
754
  */
755
755
  beforeSetModel(value, oldValue) {
756
- if (oldValue) {
757
- oldValue.destroy();
758
- }
756
+ oldValue?.destroy();
759
757
 
760
758
  if (value) {
761
759
  let me = this,
@@ -852,12 +850,11 @@ class Base extends CoreBase {
852
850
 
853
851
  me.domListeners = [];
854
852
 
855
- me.controller?.destroy();
856
- me.controller = null;
853
+ me.controller = null; // triggers destroy()
857
854
 
858
855
  me.reference && me.getController()?.removeReference(me); // remove own reference from parent controllers
859
856
 
860
- me.model?.destroy();
857
+ me.model = null; // triggers destroy()
861
858
 
862
859
  me.bind && parentModel?.removeBindings(me.id);
863
860
 
@@ -36,6 +36,15 @@ class Base extends CoreBase {
36
36
  HashHistory.on('change', this.onHashChange, this);
37
37
  }
38
38
 
39
+ /**
40
+ * @param args
41
+ */
42
+ destroy(...args) {
43
+ HashHistory.un('change', this.onHashChange, this);
44
+
45
+ super.destroy(...args);
46
+ }
47
+
39
48
  /**
40
49
  * Placeholder method which gets triggered when the hash inside the browser url changes
41
50
  * @param {Object} value
@@ -218,6 +218,8 @@ class Component extends Base {
218
218
  break;
219
219
  }
220
220
  }
221
+
222
+ me.getParent()?.removeReference(component);
221
223
  }
222
224
  }
223
225
 
@@ -111,7 +111,12 @@ class Observable extends Base {
111
111
  eventConfig.fn = eventConfig.scope[eventConfig.fn];
112
112
  }
113
113
 
114
- eventConfig.fn.apply(eventConfig.scope || me, eventConfig.data ? args.concat(eventConfig.data) : args);
114
+ // remove the listener, in case the scope no longer exists
115
+ if (eventConfig.scope && !eventConfig.scope.id) {
116
+ listeners[name].splice(i, 1);
117
+ } else {
118
+ eventConfig.fn.apply(eventConfig.scope || me, eventConfig.data ? args.concat(eventConfig.data) : args);
119
+ }
115
120
  }
116
121
  }
117
122
  }
@@ -95,9 +95,7 @@ class NeoArray extends Base {
95
95
  items.forEach(item => {
96
96
  index = arr.indexOf(item);
97
97
 
98
- if (index > -1) {
99
- arr.splice(index, 1);
100
- }
98
+ index > -1 && arr.splice(index, 1);
101
99
  });
102
100
  }
103
101