]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler): properly bail stringfication for nested slot elements
authorEvan You <yyx990803@gmail.com>
Fri, 5 Mar 2021 16:10:58 +0000 (11:10 -0500)
committerEvan You <yyx990803@gmail.com>
Fri, 5 Mar 2021 23:28:12 +0000 (18:28 -0500)
packages/compiler-core/src/transforms/hoistStatic.ts
packages/compiler-dom/src/transforms/stringifyStatic.ts

index 004a1e5a1166990020eacd210032bb905117ce73..e528fdae18851515cf86a99b4d967b3aad84c3a8 100644 (file)
@@ -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)
index 94a4e05396cca7d0cc1e2d5f3539462d56261c8c..7e4c66ad8cd8d2811b6e097d266268c0a165ad8f 100644 (file)
@@ -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
   }