fix(runtime-core): fix scopeId inheritance for component inside slots

This commit is contained in:
Evan You
2020-06-26 22:28:55 -04:00
parent 0dd5cde861
commit 978d9522e8
2 changed files with 23 additions and 4 deletions

View File

@@ -42,6 +42,7 @@ export function renderComponentRoot(
): VNode {
const {
type: Component,
parent,
vnode,
proxy,
withProxy,
@@ -148,9 +149,15 @@ export function renderComponentRoot(
}
// inherit scopeId
if (vnode.scopeId) {
root = cloneVNode(root, { [vnode.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']: '' })
}
// inherit directives
if (vnode.dirs) {
if (__DEV__ && !isElementRoot(root)) {