Browse Source

fix(codegen): support named function expression in v-on (#9709)

fix #9707
dev
GU Yiling 6 years ago
committed by Evan You
parent
commit
3433ba5bee
  1. 2
      src/compiler/codegen/events.js
  2. 5
      test/unit/modules/compiler/codegen.spec.js

2
src/compiler/codegen/events.js

@ -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$]*])*$/

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

@ -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++">',

Loading…
Cancel
Save