Skip to content

Commit 34f87f2

Browse files
committed
refactor: extract scope ID retrieval into getCurrentScopeId helper.
1 parent b3142a7 commit 34f87f2

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

packages/runtime-vapor/src/component.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -654,8 +654,7 @@ export class VaporComponentInstance implements GenericComponentInstance {
654654
: rawSlots
655655
: EMPTY_OBJ
656656

657-
const scopeOwner = getScopeOwner()
658-
this.scopeId = scopeOwner && scopeOwner.type.__scopeId
657+
this.scopeId = getCurrentScopeId()
659658

660659
// apply custom element special handling
661660
if (comp.ce) {
@@ -745,8 +744,7 @@ export function createPlainElement(
745744
;(el as any).$root = isSingleRoot
746745

747746
if (!isHydrating) {
748-
const scopeOwner = getScopeOwner()
749-
const scopeId = scopeOwner!.type.__scopeId
747+
const scopeId = getCurrentScopeId()
750748
if (scopeId) setScopeId(el, [scopeId])
751749
}
752750

@@ -1031,3 +1029,8 @@ function handleSetupResult(
10311029
popWarningContext()
10321030
}
10331031
}
1032+
1033+
export function getCurrentScopeId(): string | undefined {
1034+
const scopeOwner = getScopeOwner()
1035+
return scopeOwner && scopeOwner.type.__scopeId
1036+
}

packages/runtime-vapor/src/vdomInterop.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import {
4545
type VaporComponent,
4646
VaporComponentInstance,
4747
createComponent,
48+
getCurrentScopeId,
4849
isVaporComponent,
4950
mountComponent,
5051
unmountComponent,
@@ -60,7 +61,7 @@ import {
6061
} from '@vue/shared'
6162
import { type RawProps, rawPropsProxyHandlers } from './componentProps'
6263
import type { RawSlots, VaporSlot } from './componentSlots'
63-
import { currentSlotScopeIds, getScopeOwner } from './componentSlots'
64+
import { currentSlotScopeIds } from './componentSlots'
6465
import { renderEffect } from './renderEffect'
6566
import { _next, createTextNode } from './dom/node'
6667
import { optimizePropertyLookup } from './dom/prop'
@@ -350,8 +351,7 @@ function createVDOMComponent(
350351
frag.nodes = vnode.el as any
351352
}
352353

353-
const scopeOwner = getScopeOwner()
354-
vnode.scopeId = (scopeOwner && scopeOwner.type.__scopeId) || null
354+
vnode.scopeId = getCurrentScopeId() || null
355355
vnode.slotScopeIds = currentSlotScopeIds
356356

357357
frag.insert = (parentNode, anchor, transition) => {

0 commit comments

Comments
 (0)