Skip to content

Commit

Permalink
fix(codegen): support named function expression in v-on (#9709)
Browse files Browse the repository at this point in the history
fix #9707
  • Loading branch information
Justineo authored and yyx990803 committed Mar 18, 2019
1 parent 982d5a4 commit 3433ba5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler/codegen/events.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* @flow */

const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/
const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*(?:[\w$]+)?\s*\(/
const fnInvokeRE = /\([^)]*?\);*$/
const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/

Expand Down
5 changes: 5 additions & 0 deletions test/unit/modules/compiler/codegen.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,11 @@ describe('codegen', () => {
'<input @input="function () { current++ }">',
`with(this){return _c('input',{on:{"input":function () { current++ }}})}`
)
// normal named function
assertCodegen(
'<input @input="function fn () { current++ }">',
`with(this){return _c('input',{on:{"input":function fn () { current++ }}})}`
)
// arrow with no args
assertCodegen(
'<input @input="()=>current++">',
Expand Down

1 comment on commit 3433ba5

@bramburn
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice feature!

Please sign in to comment.