Browse Source

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

dev
Evan You 8 years ago
parent
commit
74e4e11b44
  1. 2
      src/compiler/codegen/events.js
  2. 8
      test/unit/modules/compiler/codegen.spec.js

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

8
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(
'<input @input=" onInput ">',
`with(this){return _h('input',{on:{"input": onInput }})}`
)
})
it('generate unhandled events', () => {
assertCodegen(
'<input @input="curent++">',

Loading…
Cancel
Save