From: Zardddddd60 Date: Tue, 9 Jun 2020 20:26:03 +0000 (+0800) Subject: fix(compiler-core): bail static stringfication even threshold is met (#1298) X-Git-Tag: v3.0.0-beta.15~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64ec8bfb54b97036d9cde765d923443ec8bc02b9;p=thirdparty%2Fvuejs%2Fcore.git fix(compiler-core): bail static stringfication even threshold is met (#1298) fix #1128 --- diff --git a/packages/compiler-dom/__tests__/transforms/stringifyStatic.spec.ts b/packages/compiler-dom/__tests__/transforms/stringifyStatic.spec.ts index b4d96605c0..46fe259177 100644 --- a/packages/compiler-dom/__tests__/transforms/stringifyStatic.spec.ts +++ b/packages/compiler-dom/__tests__/transforms/stringifyStatic.spec.ts @@ -225,4 +225,28 @@ describe('stringify static html', () => { type: NodeTypes.VNODE_CALL // not CALL_EXPRESSION }) }) + + test('should bail on non attribute bindings', () => { + const { ast } = compileWithStringify( + `
${repeat( + `foo`, + StringifyThresholds.ELEMENT_WITH_BINDING_COUNT + )}
` + ) + expect(ast.hoists.length).toBe(1) + expect(ast.hoists[0]).toMatchObject({ + type: NodeTypes.VNODE_CALL // not CALL_EXPRESSION + }) + + const { ast: ast2 } = compileWithStringify( + `
${repeat( + `foo`, + StringifyThresholds.ELEMENT_WITH_BINDING_COUNT + )}
` + ) + expect(ast2.hoists.length).toBe(1) + expect(ast2.hoists[0]).toMatchObject({ + type: NodeTypes.VNODE_CALL // not CALL_EXPRESSION + }) + }) }) diff --git a/packages/compiler-dom/src/transforms/stringifyStatic.ts b/packages/compiler-dom/src/transforms/stringifyStatic.ts index a354dc2cdd..6130d2395d 100644 --- a/packages/compiler-dom/src/transforms/stringifyStatic.ts +++ b/packages/compiler-dom/src/transforms/stringifyStatic.ts @@ -189,16 +189,10 @@ function analyzeNode(node: StringifiableNode): [number, number] | false { } for (let i = 0; i < node.children.length; i++) { nc++ - if (nc >= StringifyThresholds.NODE_COUNT) { - return true - } const child = node.children[i] if (child.type === NodeTypes.ELEMENT) { if (child.props.length > 0) { ec++ - if (ec >= StringifyThresholds.ELEMENT_WITH_BINDING_COUNT) { - return true - } } walk(child) if (bailed) {