@@ -99,7 +99,6 @@ export class DynamicFragment extends VaporFragment {
9999
100100 constructor ( anchorLabel ?: string ) {
101101 super ( [ ] )
102- this . parentComponent = currentInstance
103102 if ( isHydrating ) {
104103 this . anchorLabel = anchorLabel
105104 locateHydrationNode ( )
@@ -117,6 +116,7 @@ export class DynamicFragment extends VaporFragment {
117116 }
118117 this . current = key
119118
119+ const instance = currentInstance
120120 const prevSub = setActiveSub ( )
121121 const parent = isHydrating ? null : this . anchor . parentNode
122122 const transition = this . $transition
@@ -136,7 +136,7 @@ export class DynamicFragment extends VaporFragment {
136136 const mode = transition && transition . mode
137137 if ( mode ) {
138138 applyTransitionLeaveHooks ( this . nodes , transition , ( ) =>
139- this . render ( render , transition , parent ) ,
139+ this . render ( render , transition , parent , instance ) ,
140140 )
141141 parent && remove ( this . nodes , parent )
142142 if ( mode === 'out-in' ) {
@@ -148,7 +148,7 @@ export class DynamicFragment extends VaporFragment {
148148 }
149149 }
150150
151- this . render ( render , transition , parent )
151+ this . render ( render , transition , parent , instance )
152152
153153 if ( this . fallback ) {
154154 // set fallback for nested fragments
@@ -182,6 +182,7 @@ export class DynamicFragment extends VaporFragment {
182182 render : BlockFn | undefined ,
183183 transition : VaporTransitionHooks | undefined ,
184184 parent : ParentNode | null ,
185+ instance : GenericComponentInstance | null ,
185186 ) {
186187 if ( render ) {
187188 // try to reuse the kept-alive scope
@@ -195,10 +196,9 @@ export class DynamicFragment extends VaporFragment {
195196 // switch current instance to parent instance during update
196197 // ensure that the parent instance is correct for nested components
197198 let prev
198- if ( this . parentComponent && parent )
199- prev = setCurrentInstance ( this . parentComponent )
199+ if ( parent && instance ) prev = setCurrentInstance ( instance )
200200 this . nodes = this . scope . run ( render ) || [ ]
201- if ( this . parentComponent && parent ) setCurrentInstance ( ...prev ! )
201+ if ( parent && instance ) setCurrentInstance ( ...prev ! )
202202
203203 if ( transition ) {
204204 this . $transition = applyTransitionHooks ( this . nodes , transition )
0 commit comments