canvasengine 2.0.0-beta.21 → 2.0.0-beta.23

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/dist/index.js CHANGED
@@ -995,14 +995,25 @@ function destroyElement(element) {
995
995
  if (!element) {
996
996
  return;
997
997
  }
998
+ if (element.props?.children) {
999
+ for (let child of element.props.children) {
1000
+ destroyElement(child);
1001
+ }
1002
+ }
998
1003
  for (let name in element.directives) {
999
1004
  element.directives[name].onDestroy?.(element);
1000
1005
  }
1001
- element.componentInstance.onDestroy(element.parent, () => {
1002
- element.propSubscriptions.forEach((sub) => sub.unsubscribe());
1003
- element.effectSubscriptions.forEach((sub) => sub.unsubscribe());
1004
- element.effectUnmounts.forEach((fn) => fn?.());
1005
- });
1006
+ if (element.componentInstance && element.componentInstance.onDestroy) {
1007
+ element.componentInstance.onDestroy(element.parent, () => {
1008
+ element.propSubscriptions?.forEach((sub) => sub.unsubscribe());
1009
+ element.effectSubscriptions?.forEach((sub) => sub.unsubscribe());
1010
+ element.effectUnmounts?.forEach((fn) => fn?.());
1011
+ });
1012
+ } else {
1013
+ element.propSubscriptions?.forEach((sub) => sub.unsubscribe());
1014
+ element.effectSubscriptions?.forEach((sub) => sub.unsubscribe());
1015
+ element.effectUnmounts?.forEach((fn) => fn?.());
1016
+ }
1006
1017
  }
1007
1018
  function createComponent(tag, props) {
1008
1019
  if (!components[tag]) {