jedison 0.3.17 → 0.3.18

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.
@@ -1704,7 +1704,7 @@ class Instance extends EventEmitter {
1704
1704
  return this.schema;
1705
1705
  }
1706
1706
  /**
1707
- * Adds a child instance pointer to the instances list
1707
+ * Adds a child instance pointer to the instance list
1708
1708
  */
1709
1709
  register() {
1710
1710
  this.jedison.register(this);
@@ -1718,10 +1718,18 @@ class Instance extends EventEmitter {
1718
1718
  this.children.forEach(registerChildRecursive);
1719
1719
  }
1720
1720
  /**
1721
- * Deletes a child instance pointer from the instances list
1721
+ * Deletes a child instance pointer from the instance list
1722
1722
  */
1723
1723
  unregister() {
1724
1724
  this.jedison.unregister(this);
1725
+ if (this.children.length === 0) return;
1726
+ const unregisterChildRecursive = (child) => {
1727
+ this.jedison.unregister(child);
1728
+ if (child.children.length > 0) {
1729
+ child.children.forEach(unregisterChildRecursive);
1730
+ }
1731
+ };
1732
+ this.children.forEach(unregisterChildRecursive);
1725
1733
  }
1726
1734
  /**
1727
1735
  * Sets the default value of the instance based on it's type
@@ -2398,7 +2406,6 @@ class InstanceMultiple extends Instance {
2398
2406
  prepare() {
2399
2407
  this.instances = [];
2400
2408
  this.activeInstance = null;
2401
- this.lastIndex = 0;
2402
2409
  this.index = 0;
2403
2410
  this.schemas = [];
2404
2411
  this.switcherOptionValues = [];
@@ -2496,7 +2503,6 @@ class InstanceMultiple extends Instance {
2496
2503
  this.switchInstance(fittestIndex, this.value);
2497
2504
  }
2498
2505
  switchInstance(index2, value, initiator = "api") {
2499
- this.lastIndex = this.index;
2500
2506
  this.index = index2;
2501
2507
  this.activeInstance = this.instances[index2];
2502
2508
  if (isSet(value)) {