fix(sfc/scoped-style): inherit scopeId through nested HOCs with inheritAttrs: false

fix #1988
This commit is contained in:
Evan You
2020-09-01 18:56:02 -04:00
parent 5b82c48c7b
commit c0427b45ff
6 changed files with 120 additions and 42 deletions

View File

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