Skip to content

Commit

Permalink
fix(compiler-core): should not prefix object method (#1375)
Browse files Browse the repository at this point in the history
  • Loading branch information
underfin committed Jun 15, 2020
1 parent 68e2d6c commit 35dbef2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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` },
` }`
]
})
})

Expand Down
4 changes: 3 additions & 1 deletion packages/compiler-core/src/transforms/transformExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit 35dbef2

Please sign in to comment.