Skip to content

Commit 3433ba5

Browse files
Justineoyyx990803
authored andcommitted
fix(codegen): support named function expression in v-on (#9709)
fix #9707
1 parent 982d5a4 commit 3433ba5

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/compiler/codegen/events.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* @flow */
22

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

test/unit/modules/compiler/codegen.spec.js

+5
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,11 @@ describe('codegen', () => {
500500
'<input @input="function () { current++ }">',
501501
`with(this){return _c('input',{on:{"input":function () { current++ }}})}`
502502
)
503+
// normal named function
504+
assertCodegen(
505+
'<input @input="function fn () { current++ }">',
506+
`with(this){return _c('input',{on:{"input":function fn () { current++ }}})}`
507+
)
503508
// arrow with no args
504509
assertCodegen(
505510
'<input @input="()=>current++">',

0 commit comments

Comments
 (0)