]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-core): fix prod whitespace/comment removal
authorEvan You <yyx990803@gmail.com>
Thu, 11 Jun 2020 15:44:39 +0000 (11:44 -0400)
committerEvan You <yyx990803@gmail.com>
Thu, 11 Jun 2020 15:45:10 +0000 (11:45 -0400)
fix #1256

packages/compiler-core/src/parse.ts

index f8153046c5047ae75e8a0da5a5bd5b9d0f29d124..57a1592544c0d5634986a457b0eb967393b545d7 100644 (file)
@@ -216,13 +216,17 @@ function parseChildren(
               removedWhitespace = true
               nodes[i] = null as any
             } else {
-              // Otherwise, condensed consecutive whitespace inside the text down to
-              // a single space
+              // Otherwise, condensed consecutive whitespace inside the text
+              // down to a single space
               node.content = ' '
             }
           } else {
             node.content = node.content.replace(/[\t\r\n\f ]+/g, ' ')
           }
+        } else if (!__DEV__ && node.type === NodeTypes.COMMENT) {
+          // remove comment nodes in prod
+          removedWhitespace = true
+          nodes[i] = null as any
         }
       }
     } else if (parent && context.options.isPreTag(parent.tag)) {
@@ -239,12 +243,6 @@ function parseChildren(
 }
 
 function pushNode(nodes: TemplateChildNode[], node: TemplateChildNode): void {
-  // ignore comments in production
-  /* istanbul ignore next */
-  if (!__DEV__ && node.type === NodeTypes.COMMENT) {
-    return
-  }
-
   if (node.type === NodeTypes.TEXT) {
     const prev = last(nodes)
     // Merge if both this and the previous node are text and those are