Skip to content

Commit

Permalink
fix(runtime-core): avoid scopeId as attr for slot nodes with same sco…
Browse files Browse the repository at this point in the history
…peId (#1561)

fix vitejs/vite#536
  • Loading branch information
underfin authored Jul 14, 2020
1 parent 2b60870 commit 583a1c7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/runtime-core/src/componentRenderUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,16 @@ export function renderComponentRoot(

// inherit scopeId
const scopeId = vnode.scopeId
// vite#536: if subtree root is created from parent slot if would already
// have the correct scopeId, in this case adding the scopeId will cause
// it to be removed if the original slot vnode is reused.
const needScopeId = scopeId && root.scopeId !== scopeId
const treeOwnerId = parent && parent.type.__scopeId
const slotScopeId =
treeOwnerId && treeOwnerId !== scopeId ? treeOwnerId + '-s' : null
if (scopeId || slotScopeId) {
if (needScopeId || slotScopeId) {
const extras: Data = {}
if (scopeId) extras[scopeId] = ''
if (needScopeId) extras[scopeId] = ''
if (slotScopeId) extras[slotScopeId] = ''
root = cloneVNode(root, extras)
}
Expand Down

0 comments on commit 583a1c7

Please sign in to comment.