fix(compiler-dom): should bail stringification on runtime constant regardless of position
ref: vuejs/vite#157
This commit is contained in:
@@ -161,10 +161,10 @@ describe('stringify static html', () => {
|
||||
|
||||
test('should bail on runtime constant v-bind bindings', () => {
|
||||
const { ast } = compile(
|
||||
`<div><div><img src="./foo" />${repeat(
|
||||
`<div><div>${repeat(
|
||||
`<span class="foo">foo</span>`,
|
||||
StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
|
||||
)}</div></div>`,
|
||||
)}<img src="./foo" /></div></div>`,
|
||||
{
|
||||
hoistStatic: true,
|
||||
prefixIdentifiers: true,
|
||||
|
||||
@@ -185,17 +185,6 @@ function analyzeNode(node: StringiableNode): [number, number] | false {
|
||||
) {
|
||||
return bail()
|
||||
}
|
||||
// some transforms, e.g. `transformAssetUrls` in `@vue/compiler-sfc` may
|
||||
// convert static attributes into a v-bind with a constnat expresion.
|
||||
// Such constant bindings are eligible for hoisting but not for static
|
||||
// stringification because they cannot be pre-evaluated.
|
||||
if (
|
||||
p.exp &&
|
||||
(p.exp.type === NodeTypes.COMPOUND_EXPRESSION ||
|
||||
p.exp.isRuntimeConstant)
|
||||
) {
|
||||
return bail()
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < node.children.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user