fix(ssr): fix ssr scopeId on component root

This commit is contained in:
Evan You
2020-06-27 00:25:07 -04:00
parent 978d9522e8
commit afe13e0584
7 changed files with 137 additions and 46 deletions

View File

@@ -150,12 +150,14 @@ export function renderComponentRoot(
// inherit scopeId
const scopeId = vnode.scopeId
if (scopeId) {
root = cloneVNode(root, { [scopeId]: '' })
}
const treeOwnerId = parent && parent.type.__scopeId
if (treeOwnerId && treeOwnerId !== scopeId) {
root = cloneVNode(root, { [treeOwnerId + '-s']: '' })
const slotScopeId =
treeOwnerId && treeOwnerId !== scopeId ? treeOwnerId + '-s' : null
if (scopeId || slotScopeId) {
const extras: Data = {}
if (scopeId) extras[scopeId] = ''
if (slotScopeId) extras[slotScopeId] = ''
root = cloneVNode(root, extras)
}
// inherit directives