@@ -125,30 +125,26 @@ export function getSlot(
125125// Tracks slot execution context: the owner that defined the slot, and the
126126// consumer that is currently rendering it.
127127const slotOwnerStack : ( VaporComponentInstance | null ) [ ] = [ ]
128- const slotConsumerStack : ( GenericComponentInstance | null ) [ ] = [ ]
128+ const slotConsumerStack : ( VaporComponentInstance | null ) [ ] = [ ]
129129
130- export function getSlotScopeOwner ( ) : GenericComponentInstance | null {
130+ export function getSlotOwner ( ) : VaporComponentInstance | null {
131131 return slotOwnerStack . length > 0
132132 ? slotOwnerStack [ slotOwnerStack . length - 1 ]
133133 : null
134134}
135135
136- export function getSlotConsumer ( ) : GenericComponentInstance | null {
136+ export function getSlotConsumer ( ) : VaporComponentInstance | null {
137137 return slotConsumerStack . length > 0
138138 ? slotConsumerStack [ slotConsumerStack . length - 1 ]
139139 : null
140140}
141141
142142export function withVaporCtx ( fn : Function ) : BlockFn {
143- const owner =
144- ( currentInstance as VaporComponentInstance | null ) ||
145- ( getSlotScopeOwner ( ) as VaporComponentInstance | null )
146-
147- const ownerInstance = owner !
143+ const ownerInstance = currentInstance as VaporComponentInstance | null
148144 return ( ...args : any [ ] ) => {
149145 const prev = setCurrentInstance ( ownerInstance )
150146 slotOwnerStack . push ( ownerInstance )
151- slotConsumerStack . push ( prev [ 0 ] )
147+ slotConsumerStack . push ( prev [ 0 ] as VaporComponentInstance | null )
152148 try {
153149 return fn ( ...args )
154150 } finally {
@@ -170,25 +166,21 @@ export function createSlot(
170166 const _isLastInsertion = isLastInsertion
171167 if ( ! isHydrating ) resetInsertionState ( )
172168
173- const slotContext =
174- ( currentInstance as VaporComponentInstance | null ) ||
175- ( getSlotScopeOwner ( ) as VaporComponentInstance | null )
176- const owner =
177- ( getSlotScopeOwner ( ) as VaporComponentInstance | null ) || slotContext !
178- const rawSlots = slotContext ! . rawSlots
169+ const consumer = currentInstance as VaporComponentInstance
170+ const owner = getSlotOwner ( ) || consumer
171+ const rawSlots = consumer ! . rawSlots
179172 const slotProps = rawProps
180173 ? new Proxy ( rawProps , rawPropsProxyHandlers )
181174 : EMPTY_OBJ
182175
183176 let fragment : DynamicFragment
184- const contextInstance = owner
185177 if ( isRef ( rawSlots . _ ) ) {
186178 if ( isHydrating ) locateHydrationNode ( )
187- fragment = contextInstance . appContext . vapor ! . vdomSlot (
179+ fragment = owner . appContext . vapor ! . vdomSlot (
188180 rawSlots . _ ,
189181 name ,
190182 slotProps ,
191- contextInstance ,
183+ owner ,
192184 fallback ,
193185 )
194186 } else {
@@ -198,10 +190,9 @@ export function createSlot(
198190 : new DynamicFragment ( )
199191 const isDynamicName = isFunction ( name )
200192
201- // Calculate slotScopeIds once (for vdom interop)
202193 const slotScopeIds : string [ ] = [ ]
203194 if ( ! noSlotted ) {
204- const scopeId = contextInstance . type . __scopeId
195+ const scopeId = owner . type . __scopeId
205196 if ( scopeId ) {
206197 slotScopeIds . push ( `${ scopeId } -s` )
207198 }
@@ -210,14 +201,11 @@ export function createSlot(
210201 const renderSlot = ( ) => {
211202 const slotName = isFunction ( name ) ? name ( ) : name
212203
213- // in custom element mode, render <slot/> as actual slot outlets
214- // because in shadowRoot: false mode the slot element gets
215- // replaced by injected content
216204 if (
217- ( slotContext as GenericComponentInstance ) . ce ||
218- ( slotContext ! . parent &&
219- isAsyncWrapper ( slotContext ! . parent ) &&
220- slotContext ! . parent . ce )
205+ ( consumer as GenericComponentInstance ) . ce ||
206+ ( consumer . parent &&
207+ isAsyncWrapper ( consumer . parent ) &&
208+ consumer . parent . ce )
221209 ) {
222210 const el = createElement ( 'slot' )
223211 renderEffect ( ( ) => {
0 commit comments