fix(compiler-dom): bail stringification on table elements
close #1230, close #1268
This commit is contained in:
parent
64ec8bfb54
commit
a938b61edc
@ -25,7 +25,8 @@ import {
|
|||||||
toDisplayString,
|
toDisplayString,
|
||||||
normalizeClass,
|
normalizeClass,
|
||||||
normalizeStyle,
|
normalizeStyle,
|
||||||
stringifyStyle
|
stringifyStyle,
|
||||||
|
makeMap
|
||||||
} from '@vue/shared'
|
} from '@vue/shared'
|
||||||
|
|
||||||
export const enum StringifyThresholds {
|
export const enum StringifyThresholds {
|
||||||
@ -145,6 +146,8 @@ const replaceHoist = (
|
|||||||
context.hoists[context.hoists.indexOf(hoistToReplace)] = replacement
|
context.hoists[context.hoists.indexOf(hoistToReplace)] = replacement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isNonStringifiable = /*#__PURE__*/ makeMap(`thead,tr,th,tbody,td`)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* for a hoisted node, analyze it and return:
|
* for a hoisted node, analyze it and return:
|
||||||
* - false: bailed (contains runtime constant)
|
* - false: bailed (contains runtime constant)
|
||||||
@ -153,6 +156,10 @@ const replaceHoist = (
|
|||||||
* - ec is the number of element with bindings inside
|
* - ec is the number of element with bindings inside
|
||||||
*/
|
*/
|
||||||
function analyzeNode(node: StringifiableNode): [number, number] | false {
|
function analyzeNode(node: StringifiableNode): [number, number] | false {
|
||||||
|
if (node.type === NodeTypes.ELEMENT && isNonStringifiable(node.tag)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
if (node.type === NodeTypes.TEXT_CALL) {
|
if (node.type === NodeTypes.TEXT_CALL) {
|
||||||
return [1, 0]
|
return [1, 0]
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
// Make a map and return a function for checking if a key
|
/**
|
||||||
// is in that map.
|
* 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__*/
|
* IMPORTANT: all calls of this function must be prefixed with
|
||||||
// So that rollup can tree-shake them if necessary.
|
* \/\*#\_\_PURE\_\_\*\/
|
||||||
|
* So that rollup can tree-shake them if necessary.
|
||||||
|
*/
|
||||||
export function makeMap(
|
export function makeMap(
|
||||||
str: string,
|
str: string,
|
||||||
expectsLowerCase?: boolean
|
expectsLowerCase?: boolean
|
||||||
|
Loading…
Reference in New Issue
Block a user