fix v-on handler with whitespaces (fix #3893)

This commit is contained in:
Evan You 2016-10-10 19:30:19 -04:00
parent 8d2fc8e8ac
commit 74e4e11b44
2 changed files with 9 additions and 1 deletions

View File

@ -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 = {

View File

@ -244,6 +244,14 @@ describe('codegen', () => {
)
})
// #3893
it('should not treat handler with unexpected whitespace as inline statement', () => {
assertCodegen(
'<input @input=" onInput ">',
`with(this){return _h('input',{on:{"input": onInput }})}`
)
})
it('generate unhandled events', () => {
assertCodegen(
'<input @input="curent++">',