From 83af624ce25d0c992b8bdc3afff35b408fd3c6b8 Mon Sep 17 00:00:00 2001 From: Justineo Date: Fri, 15 Mar 2019 16:04:31 +0800 Subject: [PATCH] fix(codegen): inline function expression can be named inside a `v-on` expression (fix #9707) --- src/compiler/codegen/events.js | 2 +- test/unit/modules/compiler/codegen.spec.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/compiler/codegen/events.js b/src/compiler/codegen/events.js index 8ce9e1b58e1..44657e38cd8 100644 --- a/src/compiler/codegen/events.js +++ b/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$]*])*$/ diff --git a/test/unit/modules/compiler/codegen.spec.js b/test/unit/modules/compiler/codegen.spec.js index e56b25766f2..e946e218491 100644 --- a/test/unit/modules/compiler/codegen.spec.js +++ b/test/unit/modules/compiler/codegen.spec.js @@ -500,6 +500,11 @@ describe('codegen', () => { '', `with(this){return _c('input',{on:{"input":function () { current++ }}})}` ) + // normal named function + assertCodegen( + '', + `with(this){return _c('input',{on:{"input":function fn () { current++ }}})}` + ) // arrow with no args assertCodegen( '',