Skip to content

Commit

Permalink
fix(compiler): properly bail stringfication for nested slot elements
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Mar 5, 2021
1 parent aea88c3 commit f74b16c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 7 additions & 0 deletions packages/compiler-core/src/transforms/hoistStatic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,14 @@ function walk(

// walk further
if (child.type === NodeTypes.ELEMENT) {
const isComponent = child.tagType === ElementTypes.COMPONENT
if (isComponent) {
context.scopes.vSlot++
}
walk(child, context)
if (isComponent) {
context.scopes.vSlot--
}
} else if (child.type === NodeTypes.FOR) {
// Do not hoist v-for single child because it has to be a block
walk(child, context, child.children.length === 1)
Expand Down
7 changes: 2 additions & 5 deletions packages/compiler-dom/src/transforms/stringifyStatic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,8 @@ type StringifiableNode = PlainElementNode | TextCallNode
* This optimization is only performed in Node.js.
*/
export const stringifyStatic: HoistTransform = (children, context, parent) => {
if (
parent.type === NodeTypes.ELEMENT &&
(parent.tagType === ElementTypes.COMPONENT ||
parent.tagType === ElementTypes.TEMPLATE)
) {
// bail stringification for slot content
if (context.scopes.vSlot > 0) {
return
}

Expand Down

0 comments on commit f74b16c

Please sign in to comment.