Skip to content

Commit

Permalink
fix: fix function expression regex (vuejs#9922)
Browse files Browse the repository at this point in the history
  • Loading branch information
Justineo authored and Lostlover committed Dec 10, 2019
1 parent 7aebb87 commit 3f1f7f1
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*(?:[\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$]*])*$/

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 @@ -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', () => {
Expand Down

0 comments on commit 3f1f7f1

Please sign in to comment.