@@ -368,127 +368,127 @@ describe('codegen', () => {
368
368
it ( 'generate events with keycode' , ( ) => {
369
369
assertCodegen (
370
370
'<input @input.enter="onInput">' ,
371
- `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 )}}})}`
371
+ `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.apply(null, arguments )}}})}`
372
372
)
373
373
// multiple keycodes (delete)
374
374
assertCodegen (
375
375
'<input @input.delete="onInput">' ,
376
- `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 )}}})}`
376
+ `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.apply(null, arguments )}}})}`
377
377
)
378
378
// multiple keycodes (esc)
379
379
assertCodegen (
380
380
'<input @input.esc="onInput">' ,
381
- `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 )}}})}`
381
+ `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.apply(null, arguments )}}})}`
382
382
)
383
383
// multiple keycodes (space)
384
384
assertCodegen (
385
385
'<input @input.space="onInput">' ,
386
- `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 )}}})}`
386
+ `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.apply(null, arguments )}}})}`
387
387
)
388
388
// multiple keycodes (chained)
389
389
assertCodegen (
390
390
'<input @keydown.enter.delete="onInput">' ,
391
- `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 )}}})}`
391
+ `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.apply(null, arguments )}}})}`
392
392
)
393
393
// number keycode
394
394
assertCodegen (
395
395
'<input @input.13="onInput">' ,
396
- `with(this){return _c('input',{on:{"input":function($event){if(!$event.type.indexOf('key')&&$event.keyCode!==13)return null;return onInput($event )}}})}`
396
+ `with(this){return _c('input',{on:{"input":function($event){if(!$event.type.indexOf('key')&&$event.keyCode!==13)return null;return onInput.apply(null, arguments )}}})}`
397
397
)
398
398
// custom keycode
399
399
assertCodegen (
400
400
'<input @input.custom="onInput">' ,
401
- `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 )}}})}`
401
+ `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.apply(null, arguments )}}})}`
402
402
)
403
403
} )
404
404
405
405
it ( 'generate events with generic modifiers' , ( ) => {
406
406
assertCodegen (
407
407
'<input @input.stop="onInput">' ,
408
- `with(this){return _c('input',{on:{"input":function($event){$event.stopPropagation();return onInput($event )}}})}`
408
+ `with(this){return _c('input',{on:{"input":function($event){$event.stopPropagation();return onInput.apply(null, arguments )}}})}`
409
409
)
410
410
assertCodegen (
411
411
'<input @input.prevent="onInput">' ,
412
- `with(this){return _c('input',{on:{"input":function($event){$event.preventDefault();return onInput($event )}}})}`
412
+ `with(this){return _c('input',{on:{"input":function($event){$event.preventDefault();return onInput.apply(null, arguments )}}})}`
413
413
)
414
414
assertCodegen (
415
415
'<input @input.self="onInput">' ,
416
- `with(this){return _c('input',{on:{"input":function($event){if($event.target !== $event.currentTarget)return null;return onInput($event )}}})}`
416
+ `with(this){return _c('input',{on:{"input":function($event){if($event.target !== $event.currentTarget)return null;return onInput.apply(null, arguments )}}})}`
417
417
)
418
418
} )
419
419
420
420
// GitHub Issues #5146
421
421
it ( 'generate events with generic modifiers and keycode correct order' , ( ) => {
422
422
assertCodegen (
423
423
'<input @keydown.enter.prevent="onInput">' ,
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.preventDefault();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.preventDefault();return onInput.apply(null, arguments )}}})}`
425
425
)
426
426
427
427
assertCodegen (
428
428
'<input @keydown.enter.stop="onInput">' ,
429
- `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 )}}})}`
429
+ `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.apply(null, arguments )}}})}`
430
430
)
431
431
} )
432
432
433
433
it ( 'generate events with mouse event modifiers' , ( ) => {
434
434
assertCodegen (
435
435
'<input @click.ctrl="onClick">' ,
436
- `with(this){return _c('input',{on:{"click":function($event){if(!$event.ctrlKey)return null;return onClick($event )}}})}`
436
+ `with(this){return _c('input',{on:{"click":function($event){if(!$event.ctrlKey)return null;return onClick.apply(null, arguments )}}})}`
437
437
)
438
438
assertCodegen (
439
439
'<input @click.shift="onClick">' ,
440
- `with(this){return _c('input',{on:{"click":function($event){if(!$event.shiftKey)return null;return onClick($event )}}})}`
440
+ `with(this){return _c('input',{on:{"click":function($event){if(!$event.shiftKey)return null;return onClick.apply(null, arguments )}}})}`
441
441
)
442
442
assertCodegen (
443
443
'<input @click.alt="onClick">' ,
444
- `with(this){return _c('input',{on:{"click":function($event){if(!$event.altKey)return null;return onClick($event )}}})}`
444
+ `with(this){return _c('input',{on:{"click":function($event){if(!$event.altKey)return null;return onClick.apply(null, arguments )}}})}`
445
445
)
446
446
assertCodegen (
447
447
'<input @click.meta="onClick">' ,
448
- `with(this){return _c('input',{on:{"click":function($event){if(!$event.metaKey)return null;return onClick($event )}}})}`
448
+ `with(this){return _c('input',{on:{"click":function($event){if(!$event.metaKey)return null;return onClick.apply(null, arguments )}}})}`
449
449
)
450
450
assertCodegen (
451
451
'<input @click.exact="onClick">' ,
452
- `with(this){return _c('input',{on:{"click":function($event){if($event.ctrlKey||$event.shiftKey||$event.altKey||$event.metaKey)return null;return onClick($event )}}})}`
452
+ `with(this){return _c('input',{on:{"click":function($event){if($event.ctrlKey||$event.shiftKey||$event.altKey||$event.metaKey)return null;return onClick.apply(null, arguments )}}})}`
453
453
)
454
454
assertCodegen (
455
455
'<input @click.ctrl.exact="onClick">' ,
456
- `with(this){return _c('input',{on:{"click":function($event){if(!$event.ctrlKey)return null;if($event.shiftKey||$event.altKey||$event.metaKey)return null;return onClick($event )}}})}`
456
+ `with(this){return _c('input',{on:{"click":function($event){if(!$event.ctrlKey)return null;if($event.shiftKey||$event.altKey||$event.metaKey)return null;return onClick.apply(null, arguments )}}})}`
457
457
)
458
458
} )
459
459
460
460
it ( 'generate events with multiple modifiers' , ( ) => {
461
461
assertCodegen (
462
462
'<input @input.stop.prevent.self="onInput">' ,
463
- `with(this){return _c('input',{on:{"input":function($event){$event.stopPropagation();$event.preventDefault();if($event.target !== $event.currentTarget)return null;return onInput($event )}}})}`
463
+ `with(this){return _c('input',{on:{"input":function($event){$event.stopPropagation();$event.preventDefault();if($event.target !== $event.currentTarget)return null;return onInput.apply(null, arguments )}}})}`
464
464
)
465
465
} )
466
466
467
467
it ( 'generate events with capture modifier' , ( ) => {
468
468
assertCodegen (
469
469
'<input @input.capture="onInput">' ,
470
- `with(this){return _c('input',{on:{"!input":function($event){return onInput($event )}}})}`
470
+ `with(this){return _c('input',{on:{"!input":function($event){return onInput.apply(null, arguments )}}})}`
471
471
)
472
472
} )
473
473
474
474
it ( 'generate events with once modifier' , ( ) => {
475
475
assertCodegen (
476
476
'<input @input.once="onInput">' ,
477
- `with(this){return _c('input',{on:{"~input":function($event){return onInput($event )}}})}`
477
+ `with(this){return _c('input',{on:{"~input":function($event){return onInput.apply(null, arguments )}}})}`
478
478
)
479
479
} )
480
480
481
481
it ( 'generate events with capture and once modifier' , ( ) => {
482
482
assertCodegen (
483
483
'<input @input.capture.once="onInput">' ,
484
- `with(this){return _c('input',{on:{"~!input":function($event){return onInput($event )}}})}`
484
+ `with(this){return _c('input',{on:{"~!input":function($event){return onInput.apply(null, arguments )}}})}`
485
485
)
486
486
} )
487
487
488
488
it ( 'generate events with once and capture modifier' , ( ) => {
489
489
assertCodegen (
490
490
'<input @input.once.capture="onInput">' ,
491
- `with(this){return _c('input',{on:{"~!input":function($event){return onInput($event )}}})}`
491
+ `with(this){return _c('input',{on:{"~!input":function($event){return onInput.apply(null, arguments )}}})}`
492
492
)
493
493
} )
494
494
@@ -538,7 +538,7 @@ describe('codegen', () => {
538
538
// with modifiers
539
539
assertCodegen (
540
540
`<input @keyup.enter="e=>current++">` ,
541
- `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 )}}})}`
541
+ `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++).apply(null, arguments )}}})}`
542
542
)
543
543
} )
544
544
@@ -563,7 +563,7 @@ describe('codegen', () => {
563
563
it ( 'generate multiple event handlers' , ( ) => {
564
564
assertCodegen (
565
565
'<input @input="current++" @input.stop="onInput">' ,
566
- `with(this){return _c('input',{on:{"input":[function($event){current++},function($event){$event.stopPropagation();return onInput($event )}]}})}`
566
+ `with(this){return _c('input',{on:{"input":[function($event){current++},function($event){$event.stopPropagation();return onInput.apply(null, arguments )}]}})}`
567
567
)
568
568
} )
569
569
0 commit comments