Skip to content

Commit 583a1c7

Browse files
authored
fix(runtime-core): avoid scopeId as attr for slot nodes with same scopeId (#1561)
fix vitejs/vite#536
1 parent 2b60870 commit 583a1c7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/runtime-core/src/componentRenderUtils.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,16 @@ export function renderComponentRoot(
166166

167167
// inherit scopeId
168168
const scopeId = vnode.scopeId
169+
// vite#536: if subtree root is created from parent slot if would already
170+
// have the correct scopeId, in this case adding the scopeId will cause
171+
// it to be removed if the original slot vnode is reused.
172+
const needScopeId = scopeId && root.scopeId !== scopeId
169173
const treeOwnerId = parent && parent.type.__scopeId
170174
const slotScopeId =
171175
treeOwnerId && treeOwnerId !== scopeId ? treeOwnerId + '-s' : null
172-
if (scopeId || slotScopeId) {
176+
if (needScopeId || slotScopeId) {
173177
const extras: Data = {}
174-
if (scopeId) extras[scopeId] = ''
178+
if (needScopeId) extras[scopeId] = ''
175179
if (slotScopeId) extras[slotScopeId] = ''
176180
root = cloneVNode(root, extras)
177181
}

0 commit comments

Comments
 (0)