@@ -34,6 +34,7 @@ import {
3434} from './dom/hydration'
3535import { isArray } from '@vue/shared'
3636import { renderEffect } from './renderEffect'
37+ import { currentSlotOwner , setCurrentSlotOwner } from './componentSlots'
3738
3839export class VaporFragment < T extends Block = Block >
3940 implements TransitionOptions
@@ -97,8 +98,11 @@ export class DynamicFragment extends VaporFragment {
9798 ) => boolean ) [ ]
9899 onBeforeMount ?: ( ( newKey : any , nodes : Block , scope : EffectScope ) => void ) [ ]
99100
101+ slotOwner : VaporComponentInstance | null
102+
100103 constructor ( anchorLabel ?: string ) {
101104 super ( [ ] )
105+ this . slotOwner = currentSlotOwner
102106 if ( isHydrating ) {
103107 this . anchorLabel = anchorLabel
104108 locateHydrationNode ( )
@@ -204,12 +208,14 @@ export class DynamicFragment extends VaporFragment {
204208 this . scope = new EffectScope ( )
205209 }
206210
211+ // restore slot owner
212+ const prevOwner = setCurrentSlotOwner ( this . slotOwner )
207213 // switch current instance to parent instance during update
208214 // ensure that the parent instance is correct for nested components
209- let prev
210- if ( parent && instance ) prev = setCurrentInstance ( instance )
215+ const prev = parent && instance ? setCurrentInstance ( instance ) : undefined
211216 this . nodes = this . scope . run ( render ) || [ ]
212- if ( parent && instance ) setCurrentInstance ( ...prev ! )
217+ if ( prev !== undefined ) setCurrentInstance ( ...prev )
218+ setCurrentSlotOwner ( prevOwner )
213219
214220 if ( transition ) {
215221 this . $transition = applyTransitionHooks ( this . nodes , transition )
@@ -225,9 +231,12 @@ export class DynamicFragment extends VaporFragment {
225231 // apply fallthrough props during update
226232 if ( this . attrs ) {
227233 if ( this . nodes instanceof Element ) {
228- renderEffect ( ( ) =>
229- applyFallthroughProps ( this . nodes as Element , this . attrs ! ) ,
230- )
234+ // ensure render effect is cleaned up when scope is stopped
235+ this . scope . run ( ( ) => {
236+ renderEffect ( ( ) =>
237+ applyFallthroughProps ( this . nodes as Element , this . attrs ! ) ,
238+ )
239+ } )
231240 } else if (
232241 __DEV__ &&
233242 // preventing attrs fallthrough on slots
0 commit comments