@@ -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 instance = ( currentInstance as VaporComponentInstance ) || getSlotOwner ( )
170+ const ownerInstance = getSlotOwner ( ) || ( instance ! as VaporComponentInstance )
171+ const rawSlots = instance ! . 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 = ownerInstance . appContext . vapor ! . vdomSlot (
188180 rawSlots . _ ,
189181 name ,
190182 slotProps ,
191- contextInstance ,
183+ ownerInstance ,
192184 fallback ,
193185 )
194186 } else {
@@ -201,7 +193,7 @@ export function createSlot(
201193 // Calculate slotScopeIds once (for vdom interop)
202194 const slotScopeIds : string [ ] = [ ]
203195 if ( ! noSlotted ) {
204- const scopeId = contextInstance . type . __scopeId
196+ const scopeId = ownerInstance . type . __scopeId
205197 if ( scopeId ) {
206198 slotScopeIds . push ( `${ scopeId } -s` )
207199 }
@@ -214,10 +206,10 @@ export function createSlot(
214206 // because in shadowRoot: false mode the slot element gets
215207 // replaced by injected content
216208 if (
217- ( slotContext as GenericComponentInstance ) . ce ||
218- ( slotContext ! . parent &&
219- isAsyncWrapper ( slotContext ! . parent ) &&
220- slotContext ! . parent . ce )
209+ ( instance as GenericComponentInstance ) . ce ||
210+ ( instance ! . parent &&
211+ isAsyncWrapper ( instance ! . parent ) &&
212+ instance ! . parent . ce )
221213 ) {
222214 const el = createElement ( 'slot' )
223215 renderEffect ( ( ) => {
@@ -265,7 +257,7 @@ export function createSlot(
265257
266258 if ( ! isHydrating ) {
267259 if ( ! noSlotted ) {
268- const scopeId = owner . type . __scopeId
260+ const scopeId = ownerInstance . type . __scopeId
269261 if ( scopeId ) {
270262 setScopeId ( fragment , [ `${ scopeId } -s` ] )
271263 }
0 commit comments