From: underfin <2218301630@qq.com> Date: Tue, 14 Jul 2020 21:06:39 +0000 (+0800) Subject: fix(runtime-core): avoid scopeId as attr for slot nodes with same scopeId (#1561) X-Git-Tag: v3.0.0-beta.21~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=583a1c7b45e67e9cd57e411853c20509248def89;p=thirdparty%2Fvuejs%2Fcore.git fix(runtime-core): avoid scopeId as attr for slot nodes with same scopeId (#1561) fix vitejs/vite#536 --- diff --git a/packages/runtime-core/src/componentRenderUtils.ts b/packages/runtime-core/src/componentRenderUtils.ts index 7f83875a7c..9e854b265b 100644 --- a/packages/runtime-core/src/componentRenderUtils.ts +++ b/packages/runtime-core/src/componentRenderUtils.ts @@ -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) }