Skip to content

Commit 35dbef2

Browse files
authored
fix(compiler-core): should not prefix object method (#1375)
1 parent 68e2d6c commit 35dbef2

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

packages/compiler-core/__tests__/transforms/transformExpressions.spec.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -306,14 +306,19 @@ describe('compiler: expression transform', () => {
306306
]
307307
})
308308
})
309-
310309
test('should not prefix an object property key', () => {
311310
const node = parseWithExpressionTransform(
312-
`{{ { foo: bar } }}`
311+
`{{ { foo() { baz() }, value: bar } }}`
313312
) as InterpolationNode
314313
expect(node.content).toMatchObject({
315314
type: NodeTypes.COMPOUND_EXPRESSION,
316-
children: [`{ foo: `, { content: `_ctx.bar` }, ` }`]
315+
children: [
316+
`{ foo() { `,
317+
{ content: `_ctx.baz` },
318+
`() }, value: `,
319+
{ content: `_ctx.bar` },
320+
` }`
321+
]
317322
})
318323
})
319324

packages/compiler-core/src/transforms/transformExpression.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,9 @@ const isFunction = (node: Node): node is Function =>
271271
/Function(Expression|Declaration)$/.test(node.type)
272272

273273
const isStaticProperty = (node: Node): node is ObjectProperty =>
274-
node && node.type === 'ObjectProperty' && !node.computed
274+
node &&
275+
(node.type === 'ObjectProperty' || node.type === 'ObjectMethod') &&
276+
!node.computed
275277

276278
const isPropertyShorthand = (node: Node, parent: Node) => {
277279
return (

0 commit comments

Comments
 (0)