@sigx/terminal 0.1.10 → 0.1.11

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
@@ -1489,7 +1489,7 @@ function createRenderer(options) {
1489
1489
  if (internalVNode._effect) internalVNode._effect.stop();
1490
1490
  if (vnode.cleanup) vnode.cleanup();
1491
1491
  if (isComponent(vnode.type)) {
1492
- const subTree = internalVNode._subTree;
1492
+ const subTree = internalVNode._subTreeRef?.current ?? internalVNode._subTree;
1493
1493
  if (subTree) unmount(subTree, container);
1494
1494
  if (vnode.dom) hostRemove(vnode.dom);
1495
1495
  if (vnode.props?.ref) untrack(() => {
@@ -1526,6 +1526,7 @@ function createRenderer(options) {
1526
1526
  newVNode.dom = oldVNode.dom;
1527
1527
  newInternal._effect = oldInternal._effect;
1528
1528
  newInternal._subTree = oldInternal._subTree;
1529
+ newInternal._subTreeRef = oldInternal._subTreeRef;
1529
1530
  newInternal._slots = oldInternal._slots;
1530
1531
  const props = oldInternal._componentProps;
1531
1532
  newInternal._componentProps = props;
@@ -1779,13 +1780,22 @@ function createRenderer(options) {
1779
1780
  }
1780
1781
  if (renderFn) {
1781
1782
  ctx.renderFn = renderFn;
1783
+ const subTreeRef = { current: null };
1784
+ internalVNode._subTreeRef = subTreeRef;
1782
1785
  const componentEffect = effect(() => {
1783
1786
  const prevInstance = setCurrentInstance(ctx);
1784
1787
  try {
1785
1788
  const subTreeResult = ctx.renderFn();
1786
- if (subTreeResult == null) return;
1789
+ if (subTreeResult == null) {
1790
+ if (subTreeRef.current) {
1791
+ unmount(subTreeRef.current, container);
1792
+ subTreeRef.current = null;
1793
+ internalVNode._subTree = null;
1794
+ }
1795
+ return;
1796
+ }
1787
1797
  const subTree = normalizeSubTree(subTreeResult);
1788
- const prevSubTree = internalVNode._subTree;
1798
+ const prevSubTree = subTreeRef.current;
1789
1799
  if (prevSubTree) {
1790
1800
  const prevFocus = hostGetActiveElement ? hostGetActiveElement() : null;
1791
1801
  patch(prevSubTree, subTree, container);
@@ -1793,6 +1803,7 @@ function createRenderer(options) {
1793
1803
  notifyComponentUpdated(currentAppContext, componentInstance);
1794
1804
  updatedHooks.forEach((hook) => hook());
1795
1805
  } else mount(subTree, container, anchor);
1806
+ subTreeRef.current = subTree;
1796
1807
  internalVNode._subTree = subTree;
1797
1808
  } catch (err) {
1798
1809
  if (!handleComponentError(currentAppContext, err, componentInstance, "render")) throw err;