]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test: skip optimizing single text root
authorEvan You <yyx990803@gmail.com>
Mon, 2 Dec 2019 20:49:59 +0000 (15:49 -0500)
committerEvan You <yyx990803@gmail.com>
Mon, 2 Dec 2019 20:49:59 +0000 (15:49 -0500)
packages/compiler-core/src/transforms/transformText.ts

index 91d5d5076ad40f3bcbe59af480030bb19b7ca476..3cc7518a8b0c3f160c4a47f3193b69473827f342 100644 (file)
@@ -56,12 +56,14 @@ export const transformText: NodeTransform = (node, context) => {
 
       if (
         !hasText ||
-        // if this is a plain element with a single text child, leave it as-is
-        // since the runtime has dedicated fast path for this by directly
+        // if this is a plain element with a single text child, leave it
+        // as-is since the runtime has dedicated fast path for this by directly
         // setting textContent of the element.
-        (node.type === NodeTypes.ELEMENT &&
-          node.tagType === ElementTypes.ELEMENT &&
-          children.length === 1)
+        // for component root it's always normalized anyway.
+        (children.length === 1 &&
+          (node.type === NodeTypes.ROOT ||
+            (node.type === NodeTypes.ELEMENT &&
+              node.tagType === ElementTypes.ELEMENT)))
       ) {
         return
       }