From 74e4e11b4478439e581818c483d27038cbbd62fb Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 10 Oct 2016 19:30:19 -0400 Subject: [PATCH] fix v-on handler with whitespaces (fix #3893) --- src/compiler/codegen/events.js | 2 +- test/unit/modules/compiler/codegen.spec.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/compiler/codegen/events.js b/src/compiler/codegen/events.js index cb0ca49a..79c79404 100644 --- a/src/compiler/codegen/events.js +++ b/src/compiler/codegen/events.js @@ -1,6 +1,6 @@ /* @flow */ -const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?'\]|\[".*?"\]|\[\d+\]|\[[A-Za-z_$][\w$]*\])*$/ +const simplePathRE = /^\s*[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?'\]|\[".*?"\]|\[\d+\]|\[[A-Za-z_$][\w$]*\])*\s*$/ // keyCode aliases const keyCodes = { diff --git a/test/unit/modules/compiler/codegen.spec.js b/test/unit/modules/compiler/codegen.spec.js index 01ecdb0f..ad0f27e0 100644 --- a/test/unit/modules/compiler/codegen.spec.js +++ b/test/unit/modules/compiler/codegen.spec.js @@ -244,6 +244,14 @@ describe('codegen', () => { ) }) + // #3893 + it('should not treat handler with unexpected whitespace as inline statement', () => { + assertCodegen( + '', + `with(this){return _h('input',{on:{"input": onInput }})}` + ) + }) + it('generate unhandled events', () => { assertCodegen( '',