From: Evan You Date: Fri, 5 Mar 2021 16:10:58 +0000 (-0500) Subject: fix(compiler): properly bail stringfication for nested slot elements X-Git-Tag: v3.0.8~65 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f74b16ccfe42abddf6abfa6105900ad9b8124a96;p=thirdparty%2Fvuejs%2Fcore.git fix(compiler): properly bail stringfication for nested slot elements --- diff --git a/packages/compiler-core/src/transforms/hoistStatic.ts b/packages/compiler-core/src/transforms/hoistStatic.ts index 004a1e5a11..e528fdae18 100644 --- a/packages/compiler-core/src/transforms/hoistStatic.ts +++ b/packages/compiler-core/src/transforms/hoistStatic.ts @@ -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) diff --git a/packages/compiler-dom/src/transforms/stringifyStatic.ts b/packages/compiler-dom/src/transforms/stringifyStatic.ts index 94a4e05396..7e4c66ad8c 100644 --- a/packages/compiler-dom/src/transforms/stringifyStatic.ts +++ b/packages/compiler-dom/src/transforms/stringifyStatic.ts @@ -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 }