Skip to content

Commit 569b728

Browse files
Justineoyyx990803
authored andcommittedApr 25, 2019
fix: fix function expression regex (#9922)
fix #9920
1 parent ab50e8e commit 569b728

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*(?:[\w$]+)?\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
@@ -345,6 +345,11 @@ describe('codegen', () => {
345345
`<input @input="onInput(');[\\'());');">`,
346346
`with(this){return _c('input',{on:{"input":function($event){onInput(');[\\'());');}}})}`
347347
)
348+
// function name including a `function` part (#9920)
349+
assertCodegen(
350+
'<input @input="functionName()">',
351+
`with(this){return _c('input',{on:{"input":function($event){return functionName()}}})}`
352+
)
348353
})
349354

350355
it('generate events with multiple statements', () => {

0 commit comments

Comments
 (0)
Please sign in to comment.