]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-dom): bail stringification on table elements
authorEvan You <yyx990803@gmail.com>
Tue, 9 Jun 2020 21:02:27 +0000 (17:02 -0400)
committerEvan You <yyx990803@gmail.com>
Tue, 9 Jun 2020 21:02:27 +0000 (17:02 -0400)
close #1230, close #1268

packages/compiler-dom/src/transforms/stringifyStatic.ts
packages/shared/src/makeMap.ts

index 6130d2395d3f9a093b41d40aa38d96e8959e0b0a..1758714253bab8bd42f01c5951fa06d7e8fc33bd 100644 (file)
@@ -25,7 +25,8 @@ import {
   toDisplayString,
   normalizeClass,
   normalizeStyle,
-  stringifyStyle
+  stringifyStyle,
+  makeMap
 } from '@vue/shared'
 
 export const enum StringifyThresholds {
@@ -145,6 +146,8 @@ const replaceHoist = (
   context.hoists[context.hoists.indexOf(hoistToReplace)] = replacement
 }
 
+const isNonStringifiable = /*#__PURE__*/ makeMap(`thead,tr,th,tbody,td`)
+
 /**
  * for a hoisted node, analyze it and return:
  * - false: bailed (contains runtime constant)
@@ -153,6 +156,10 @@ const replaceHoist = (
  *   - ec is the number of element with bindings inside
  */
 function analyzeNode(node: StringifiableNode): [number, number] | false {
+  if (node.type === NodeTypes.ELEMENT && isNonStringifiable(node.tag)) {
+    return false
+  }
+
   if (node.type === NodeTypes.TEXT_CALL) {
     return [1, 0]
   }
index 712c3c2d7bfa6d5bd560b1d66794d6a6d4dfe992..b598704c6731d449d42c87f9d3f21eae501ebf72 100644 (file)
@@ -1,8 +1,10 @@
-// Make a map and return a function for checking if a key
-// is in that map.
-//
-// IMPORTANT: all calls of this function must be prefixed with /*#__PURE__*/
-// So that rollup can tree-shake them if necessary.
+/**
+ * Make a map and return a function for checking if a key
+ * is in that map.
+ * IMPORTANT: all calls of this function must be prefixed with
+ * \/\*#\_\_PURE\_\_\*\/
+ * So that rollup can tree-shake them if necessary.
+ */
 export function makeMap(
   str: string,
   expectsLowerCase?: boolean