fix: fix function expression regex (#9922)

fix #9920
This commit is contained in:
GU Yiling 2019-04-25 21:04:36 +08:00 committed by Evan You
parent ab50e8e1da
commit 569b728ab1
2 changed files with 6 additions and 1 deletions

View File

@ -1,6 +1,6 @@
/* @flow */
const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*(?:[\w$]+)?\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$]*])*$/

View File

@ -345,6 +345,11 @@ describe('codegen', () => {
`<input @input="onInput(');[\\'());');">`,
`with(this){return _c('input',{on:{"input":function($event){onInput(');[\\'());');}}})}`
)
// function name including a `function` part (#9920)
assertCodegen(
'<input @input="functionName()">',
`with(this){return _c('input',{on:{"input":function($event){return functionName()}}})}`
)
})
it('generate events with multiple statements', () => {