@@ -50,7 +50,7 @@ import { hasClassAttr } from '../shared/utils/scoped-styles';
5050import { serializeAttribute } from '../shared/utils/styles' ;
5151import { isArray , type ValueOrPromise } from '../shared/utils/types' ;
5252import { trackSignalAndAssignHost } from '../use/use-core' ;
53- import { TaskFlags , cleanupTask , isTask } from '../use/use-task' ;
53+ import { TaskFlags , isTask } from '../use/use-task' ;
5454import type { DomContainer } from './dom-container' ;
5555import { VNodeFlags , type ClientAttrs , type ClientContainer } from './types' ;
5656import { mapApp_findIndx , mapArray_set } from './util-mapArray' ;
@@ -81,6 +81,9 @@ import {
8181} from './vnode' ;
8282import type { ElementVNode , TextVNode , VNode , VirtualVNode } from './vnode-impl' ;
8383import { getAttributeNamespace , getNewElementNamespaceData } from './vnode-namespace' ;
84+ import { cleanupDestroyable , isDestroyable } from '../use/utils/destroyable' ;
85+ import { SignalImpl } from '../reactive-primitives/impl/signal-impl' ;
86+ import { isStore } from '../reactive-primitives/impl/store' ;
8487
8588export const vnode_diff = (
8689 container : ClientContainer ,
@@ -1527,29 +1530,33 @@ export function cleanup(container: ClientContainer, vNode: VNode) {
15271530 if ( type & VNodeFlags . ELEMENT_OR_VIRTUAL_MASK ) {
15281531 clearAllEffects ( container , vCursor ) ;
15291532 markVNodeAsDeleted ( vCursor ) ;
1530- // Only elements and virtual nodes need to be traversed for children
1531- if ( type & VNodeFlags . Virtual ) {
1533+
1534+ const isComponent =
1535+ type & VNodeFlags . Virtual &&
1536+ ( vCursor as VirtualVNode ) . getProp < OnRenderFn < any > | null > ( OnRenderProp , null ) !== null ;
1537+ if ( isComponent ) {
1538+ // cleanup q:seq content
15321539 const seq = container . getHostProp < Array < any > > ( vCursor as VirtualVNode , ELEMENT_SEQ ) ;
15331540 if ( seq ) {
15341541 for ( let i = 0 ; i < seq . length ; i ++ ) {
15351542 const obj = seq [ i ] ;
15361543 if ( isTask ( obj ) ) {
1537- const task = obj ;
1538- clearAllEffects ( container , task ) ;
1539- if ( task . $flags$ & TaskFlags . VISIBLE_TASK ) {
1540- container . $scheduler$ ( ChoreType . CLEANUP_VISIBLE , task ) ;
1541- } else {
1542- cleanupTask ( task ) ;
1544+ clearAllEffects ( container , obj ) ;
1545+ if ( obj . $flags$ & TaskFlags . VISIBLE_TASK ) {
1546+ container . $scheduler$ ( ChoreType . CLEANUP_VISIBLE , obj ) ;
1547+ // don't call cleanupDestroyable yet, do it by the scheduler
1548+ continue ;
15431549 }
1550+ } else if ( obj instanceof SignalImpl || isStore ( obj ) ) {
1551+ clearAllEffects ( container , obj ) ;
1552+ }
1553+
1554+ if ( isDestroyable ( obj ) ) {
1555+ cleanupDestroyable ( obj ) ;
15441556 }
15451557 }
15461558 }
1547- }
15481559
1549- const isComponent =
1550- type & VNodeFlags . Virtual &&
1551- ( vCursor as VirtualVNode ) . getProp < OnRenderFn < any > | null > ( OnRenderProp , null ) !== null ;
1552- if ( isComponent ) {
15531560 // SPECIAL CASE: If we are a component, we need to descend into the projected content and release the content.
15541561 const attrs = vnode_getProps ( vCursor as VirtualVNode ) ;
15551562 for ( let i = 0 ; i < attrs . length ; i = i + 2 ) {
0 commit comments