|
|
@ -356,37 +356,37 @@ describe('codegen', () => { |
|
|
|
it('generate events with keycode', () => { |
|
|
|
assertCodegen( |
|
|
|
'<input @input.enter="onInput">', |
|
|
|
`with(this){return _c('input',{on:{"input":function($event){if(!('button' in $event)&&_k($event.keyCode,"enter",13,$event.key,"Enter"))return null;return onInput($event)}}})}` |
|
|
|
`with(this){return _c('input',{on:{"input":function($event){if(('keyCode' in $event)&&_k($event.keyCode,"enter",13,$event.key,"Enter"))return null;return onInput($event)}}})}` |
|
|
|
) |
|
|
|
// multiple keycodes (delete)
|
|
|
|
assertCodegen( |
|
|
|
'<input @input.delete="onInput">', |
|
|
|
`with(this){return _c('input',{on:{"input":function($event){if(!('button' in $event)&&_k($event.keyCode,"delete",[8,46],$event.key,["Backspace","Delete","Del"]))return null;return onInput($event)}}})}` |
|
|
|
`with(this){return _c('input',{on:{"input":function($event){if(('keyCode' in $event)&&_k($event.keyCode,"delete",[8,46],$event.key,["Backspace","Delete","Del"]))return null;return onInput($event)}}})}` |
|
|
|
) |
|
|
|
// multiple keycodes (esc)
|
|
|
|
assertCodegen( |
|
|
|
'<input @input.esc="onInput">', |
|
|
|
`with(this){return _c('input',{on:{"input":function($event){if(!('button' in $event)&&_k($event.keyCode,"esc",27,$event.key,["Esc","Escape"]))return null;return onInput($event)}}})}` |
|
|
|
`with(this){return _c('input',{on:{"input":function($event){if(('keyCode' in $event)&&_k($event.keyCode,"esc",27,$event.key,["Esc","Escape"]))return null;return onInput($event)}}})}` |
|
|
|
) |
|
|
|
// multiple keycodes (space)
|
|
|
|
assertCodegen( |
|
|
|
'<input @input.space="onInput">', |
|
|
|
`with(this){return _c('input',{on:{"input":function($event){if(!('button' in $event)&&_k($event.keyCode,"space",32,$event.key,[" ","Spacebar"]))return null;return onInput($event)}}})}` |
|
|
|
`with(this){return _c('input',{on:{"input":function($event){if(('keyCode' in $event)&&_k($event.keyCode,"space",32,$event.key,[" ","Spacebar"]))return null;return onInput($event)}}})}` |
|
|
|
) |
|
|
|
// multiple keycodes (chained)
|
|
|
|
assertCodegen( |
|
|
|
'<input @keydown.enter.delete="onInput">', |
|
|
|
`with(this){return _c('input',{on:{"keydown":function($event){if(!('button' in $event)&&_k($event.keyCode,"enter",13,$event.key,"Enter")&&_k($event.keyCode,"delete",[8,46],$event.key,["Backspace","Delete","Del"]))return null;return onInput($event)}}})}` |
|
|
|
`with(this){return _c('input',{on:{"keydown":function($event){if(('keyCode' in $event)&&_k($event.keyCode,"enter",13,$event.key,"Enter")&&_k($event.keyCode,"delete",[8,46],$event.key,["Backspace","Delete","Del"]))return null;return onInput($event)}}})}` |
|
|
|
) |
|
|
|
// number keycode
|
|
|
|
assertCodegen( |
|
|
|
'<input @input.13="onInput">', |
|
|
|
`with(this){return _c('input',{on:{"input":function($event){if(!('button' in $event)&&$event.keyCode!==13)return null;return onInput($event)}}})}` |
|
|
|
`with(this){return _c('input',{on:{"input":function($event){if(('keyCode' in $event)&&$event.keyCode!==13)return null;return onInput($event)}}})}` |
|
|
|
) |
|
|
|
// custom keycode
|
|
|
|
assertCodegen( |
|
|
|
'<input @input.custom="onInput">', |
|
|
|
`with(this){return _c('input',{on:{"input":function($event){if(!('button' in $event)&&_k($event.keyCode,"custom",undefined,$event.key,undefined))return null;return onInput($event)}}})}` |
|
|
|
`with(this){return _c('input',{on:{"input":function($event){if(('keyCode' in $event)&&_k($event.keyCode,"custom",undefined,$event.key,undefined))return null;return onInput($event)}}})}` |
|
|
|
) |
|
|
|
}) |
|
|
|
|
|
|
@ -409,12 +409,12 @@ describe('codegen', () => { |
|
|
|
it('generate events with generic modifiers and keycode correct order', () => { |
|
|
|
assertCodegen( |
|
|
|
'<input @keydown.enter.prevent="onInput">', |
|
|
|
`with(this){return _c('input',{on:{"keydown":function($event){if(!('button' in $event)&&_k($event.keyCode,"enter",13,$event.key,"Enter"))return null;$event.preventDefault();return onInput($event)}}})}` |
|
|
|
`with(this){return _c('input',{on:{"keydown":function($event){if(('keyCode' in $event)&&_k($event.keyCode,"enter",13,$event.key,"Enter"))return null;$event.preventDefault();return onInput($event)}}})}` |
|
|
|
) |
|
|
|
|
|
|
|
assertCodegen( |
|
|
|
'<input @keydown.enter.stop="onInput">', |
|
|
|
`with(this){return _c('input',{on:{"keydown":function($event){if(!('button' in $event)&&_k($event.keyCode,"enter",13,$event.key,"Enter"))return null;$event.stopPropagation();return onInput($event)}}})}` |
|
|
|
`with(this){return _c('input',{on:{"keydown":function($event){if(('keyCode' in $event)&&_k($event.keyCode,"enter",13,$event.key,"Enter"))return null;$event.stopPropagation();return onInput($event)}}})}` |
|
|
|
) |
|
|
|
}) |
|
|
|
|
|
|
@ -521,7 +521,7 @@ describe('codegen', () => { |
|
|
|
// with modifiers
|
|
|
|
assertCodegen( |
|
|
|
`<input @keyup.enter="e=>current++">`, |
|
|
|
`with(this){return _c('input',{on:{"keyup":function($event){if(!('button' in $event)&&_k($event.keyCode,"enter",13,$event.key,"Enter"))return null;return (e=>current++)($event)}}})}` |
|
|
|
`with(this){return _c('input',{on:{"keyup":function($event){if(('keyCode' in $event)&&_k($event.keyCode,"enter",13,$event.key,"Enter"))return null;return (e=>current++)($event)}}})}` |
|
|
|
) |
|
|
|
}) |
|
|
|
|
|
|
|