Skip to content

Commit f74b16c

Browse files
committed
fix(compiler): properly bail stringfication for nested slot elements
1 parent aea88c3 commit f74b16c

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

packages/compiler-core/src/transforms/hoistStatic.ts

+7
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,14 @@ function walk(
111111

112112
// walk further
113113
if (child.type === NodeTypes.ELEMENT) {
114+
const isComponent = child.tagType === ElementTypes.COMPONENT
115+
if (isComponent) {
116+
context.scopes.vSlot++
117+
}
114118
walk(child, context)
119+
if (isComponent) {
120+
context.scopes.vSlot--
121+
}
115122
} else if (child.type === NodeTypes.FOR) {
116123
// Do not hoist v-for single child because it has to be a block
117124
walk(child, context, child.children.length === 1)

packages/compiler-dom/src/transforms/stringifyStatic.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,8 @@ type StringifiableNode = PlainElementNode | TextCallNode
6060
* This optimization is only performed in Node.js.
6161
*/
6262
export const stringifyStatic: HoistTransform = (children, context, parent) => {
63-
if (
64-
parent.type === NodeTypes.ELEMENT &&
65-
(parent.tagType === ElementTypes.COMPONENT ||
66-
parent.tagType === ElementTypes.TEMPLATE)
67-
) {
63+
// bail stringification for slot content
64+
if (context.scopes.vSlot > 0) {
6865
return
6966
}
7067

0 commit comments

Comments
 (0)