Skip to content

Commit 078e754

Browse files
committed
refactor: allow getScopeOwner to return null and add non-null assertion for instance access.
1 parent 11c95db commit 078e754

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/runtime-vapor/src/component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1032,5 +1032,5 @@ function handleSetupResult(
10321032

10331033
export function getCurrentScopeId(): string | undefined {
10341034
const scopeOwner = getScopeOwner()
1035-
return scopeOwner && scopeOwner.type.__scopeId
1035+
return scopeOwner ? scopeOwner.type.__scopeId : undefined
10361036
}

packages/runtime-vapor/src/componentSlots.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ export function setCurrentSlotOwner(
145145
* Get the effective slot instance for accessing rawSlots and scopeId.
146146
* Prefers currentSlotOwner (if inside a slot), falls back to currentInstance.
147147
*/
148-
export function getScopeOwner(): VaporComponentInstance {
149-
return (currentSlotOwner || currentInstance) as VaporComponentInstance
148+
export function getScopeOwner(): VaporComponentInstance | null {
149+
return (currentSlotOwner || currentInstance) as VaporComponentInstance | null
150150
}
151151

152152
/**
@@ -180,7 +180,7 @@ export function createSlot(
180180
const _isLastInsertion = isLastInsertion
181181
if (!isHydrating) resetInsertionState()
182182

183-
const instance = getScopeOwner()
183+
const instance = getScopeOwner()!
184184
const rawSlots = instance.rawSlots
185185
const slotProps = rawProps
186186
? new Proxy(rawProps, rawPropsProxyHandlers)

0 commit comments

Comments
 (0)