@@ -363,37 +363,37 @@ describe('codegen', () => {
363363 it ( 'generate events with keycode' , ( ) => {
364364 assertCodegen (
365365 '<input @input.enter="onInput">' ,
366- `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)}}})}`
366+ `with(this){return _c('input',{on:{"input":function($event){if(!$event.type.indexOf('key' )&&_k($event.keyCode,"enter",13,$event.key,"Enter"))return null;return onInput($event)}}})}`
367367 )
368368 // multiple keycodes (delete)
369369 assertCodegen (
370370 '<input @input.delete="onInput">' ,
371- `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)}}})}`
371+ `with(this){return _c('input',{on:{"input":function($event){if(!$event.type.indexOf('key' )&&_k($event.keyCode,"delete",[8,46],$event.key,["Backspace","Delete","Del"]))return null;return onInput($event)}}})}`
372372 )
373373 // multiple keycodes (esc)
374374 assertCodegen (
375375 '<input @input.esc="onInput">' ,
376- `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)}}})}`
376+ `with(this){return _c('input',{on:{"input":function($event){if(!$event.type.indexOf('key' )&&_k($event.keyCode,"esc",27,$event.key,["Esc","Escape"]))return null;return onInput($event)}}})}`
377377 )
378378 // multiple keycodes (space)
379379 assertCodegen (
380380 '<input @input.space="onInput">' ,
381- `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)}}})}`
381+ `with(this){return _c('input',{on:{"input":function($event){if(!$event.type.indexOf('key' )&&_k($event.keyCode,"space",32,$event.key,[" ","Spacebar"]))return null;return onInput($event)}}})}`
382382 )
383383 // multiple keycodes (chained)
384384 assertCodegen (
385385 '<input @keydown.enter.delete="onInput">' ,
386- `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)}}})}`
386+ `with(this){return _c('input',{on:{"keydown":function($event){if(!$event.type.indexOf('key' )&&_k($event.keyCode,"enter",13,$event.key,"Enter")&&_k($event.keyCode,"delete",[8,46],$event.key,["Backspace","Delete","Del"]))return null;return onInput($event)}}})}`
387387 )
388388 // number keycode
389389 assertCodegen (
390390 '<input @input.13="onInput">' ,
391- `with(this){return _c('input',{on:{"input":function($event){if(('keyCode' in $event )&&$event.keyCode!==13)return null;return onInput($event)}}})}`
391+ `with(this){return _c('input',{on:{"input":function($event){if(!$event.type.indexOf('key' )&&$event.keyCode!==13)return null;return onInput($event)}}})}`
392392 )
393393 // custom keycode
394394 assertCodegen (
395395 '<input @input.custom="onInput">' ,
396- `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)}}})}`
396+ `with(this){return _c('input',{on:{"input":function($event){if(!$event.type.indexOf('key' )&&_k($event.keyCode,"custom",undefined,$event.key,undefined))return null;return onInput($event)}}})}`
397397 )
398398 } )
399399
@@ -416,12 +416,12 @@ describe('codegen', () => {
416416 it ( 'generate events with generic modifiers and keycode correct order' , ( ) => {
417417 assertCodegen (
418418 '<input @keydown.enter.prevent="onInput">' ,
419- `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)}}})}`
419+ `with(this){return _c('input',{on:{"keydown":function($event){if(!$event.type.indexOf('key' )&&_k($event.keyCode,"enter",13,$event.key,"Enter"))return null;$event.preventDefault();return onInput($event)}}})}`
420420 )
421421
422422 assertCodegen (
423423 '<input @keydown.enter.stop="onInput">' ,
424- `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)}}})}`
424+ `with(this){return _c('input',{on:{"keydown":function($event){if(!$event.type.indexOf('key' )&&_k($event.keyCode,"enter",13,$event.key,"Enter"))return null;$event.stopPropagation();return onInput($event)}}})}`
425425 )
426426 } )
427427
@@ -528,7 +528,7 @@ describe('codegen', () => {
528528 // with modifiers
529529 assertCodegen (
530530 `<input @keyup.enter="e=>current++">` ,
531- `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)}}})}`
531+ `with(this){return _c('input',{on:{"keyup":function($event){if(!$event.type.indexOf('key' )&&_k($event.keyCode,"enter",13,$event.key,"Enter"))return null;return (e=>current++)($event)}}})}`
532532 )
533533 } )
534534
0 commit comments