]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-core): should not prefix object method (#1375)
authorunderfin <2218301630@qq.com>
Mon, 15 Jun 2020 15:20:00 +0000 (23:20 +0800)
committerGitHub <noreply@github.com>
Mon, 15 Jun 2020 15:20:00 +0000 (11:20 -0400)
packages/compiler-core/__tests__/transforms/transformExpressions.spec.ts
packages/compiler-core/src/transforms/transformExpression.ts

index 4bab03c00f319b1d5608bff3fdb74e65432e5c66..870024a4b9c7221d73a208b378913ed66b4cf558 100644 (file)
@@ -306,14 +306,19 @@ describe('compiler: expression transform', () => {
       ]
     })
   })
-
   test('should not prefix an object property key', () => {
     const node = parseWithExpressionTransform(
-      `{{ { foo: bar } }}`
+      `{{ { foo() { baz() }, value: bar } }}`
     ) as InterpolationNode
     expect(node.content).toMatchObject({
       type: NodeTypes.COMPOUND_EXPRESSION,
-      children: [`{ foo: `, { content: `_ctx.bar` }, ` }`]
+      children: [
+        `{ foo() { `,
+        { content: `_ctx.baz` },
+        `() }, value: `,
+        { content: `_ctx.bar` },
+        ` }`
+      ]
     })
   })
 
index 0d3f145e77bb8be408d73ee579c796a533b83e02..b1da05b4589aa323cb439e32759de4a2b7e813bd 100644 (file)
@@ -271,7 +271,9 @@ const isFunction = (node: Node): node is Function =>
   /Function(Expression|Declaration)$/.test(node.type)
 
 const isStaticProperty = (node: Node): node is ObjectProperty =>
-  node && node.type === 'ObjectProperty' && !node.computed
+  node &&
+  (node.type === 'ObjectProperty' || node.type === 'ObjectMethod') &&
+  !node.computed
 
 const isPropertyShorthand = (node: Node, parent: Node) => {
   return (