Skip to content

Commit 74e4e11

Browse files
committed
fix v-on handler with whitespaces (fix #3893)
1 parent 8d2fc8e commit 74e4e11

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Diff for: src/compiler/codegen/events.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* @flow */
22

3-
const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?'\]|\[".*?"\]|\[\d+\]|\[[A-Za-z_$][\w$]*\])*$/
3+
const simplePathRE = /^\s*[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?'\]|\[".*?"\]|\[\d+\]|\[[A-Za-z_$][\w$]*\])*\s*$/
44

55
// keyCode aliases
66
const keyCodes = {

Diff for: test/unit/modules/compiler/codegen.spec.js

+8
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,14 @@ describe('codegen', () => {
244244
)
245245
})
246246

247+
// #3893
248+
it('should not treat handler with unexpected whitespace as inline statement', () => {
249+
assertCodegen(
250+
'<input @input=" onInput ">',
251+
`with(this){return _h('input',{on:{"input": onInput }})}`
252+
)
253+
})
254+
247255
it('generate unhandled events', () => {
248256
assertCodegen(
249257
'<input @input="curent++">',

0 commit comments

Comments
 (0)