fix(compiler-dom): avoid bailing stringification on setup const bindings

This commit is contained in:
Evan You
2021-12-06 11:53:02 +08:00
parent 4713578367
commit 29beda7c6f
5 changed files with 103 additions and 31 deletions

View File

@@ -14,7 +14,8 @@ import {
ElementTypes,
PlainElementNode,
JSChildNode,
TextCallNode
TextCallNode,
ConstantTypes
} from '@vue/compiler-core'
import {
isVoidTag,
@@ -171,7 +172,7 @@ const isNonStringifiable = /*#__PURE__*/ makeMap(
/**
* for a hoisted node, analyze it and return:
* - false: bailed (contains runtime constant)
* - false: bailed (contains non-stringifiable props or runtime constant)
* - [nc, ec] where
* - nc is the number of nodes inside
* - ec is the number of element with bindings inside
@@ -216,6 +217,13 @@ function analyzeNode(node: StringifiableNode): [number, number] | false {
) {
return bail()
}
if (
p.exp &&
(p.exp.type === NodeTypes.COMPOUND_EXPRESSION ||
p.exp.constType < ConstantTypes.CAN_STRINGIFY)
) {
return bail()
}
}
}
for (let i = 0; i < node.children.length; i++) {