fix(compiler-ssr): fix attr fallthrough for transition/keep-alive as template root
fix #3981
This commit is contained in:
@@ -7,7 +7,8 @@ import {
|
||||
RootNode,
|
||||
TemplateChildNode,
|
||||
ParentNode,
|
||||
findDir
|
||||
findDir,
|
||||
isBuiltInType
|
||||
} from '@vue/compiler-dom'
|
||||
|
||||
const hasSingleChild = (node: ParentNode): boolean =>
|
||||
@@ -21,6 +22,18 @@ export const ssrInjectFallthroughAttrs: NodeTransform = (node, context) => {
|
||||
context.identifiers._attrs = 1
|
||||
}
|
||||
|
||||
if (
|
||||
node.type === NodeTypes.ELEMENT &&
|
||||
node.tagType === ElementTypes.COMPONENT &&
|
||||
(isBuiltInType(node.tag, 'Transition') ||
|
||||
isBuiltInType(node.tag, 'KeepAlive'))
|
||||
) {
|
||||
if (hasSingleChild(node)) {
|
||||
injectFallthroughAttrs(node.children[0])
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
const parent = context.parent
|
||||
if (!parent || parent.type !== NodeTypes.ROOT) {
|
||||
return
|
||||
|
||||
@@ -180,7 +180,8 @@ export function ssrProcessComponent(
|
||||
} else if (component === TRANSITION_GROUP) {
|
||||
return ssrProcessTransitionGroup(node, context)
|
||||
} else {
|
||||
// real fall-through (e.g. KeepAlive): just render its children.
|
||||
// real fall-through: Transition / KeepAlive
|
||||
// just render its children.
|
||||
processChildren(node.children, context)
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user