@@ -356,6 +356,83 @@ describe('component: emit', () => {
356
356
expect ( fn2 ) . toHaveBeenCalledWith ( 'two' )
357
357
} )
358
358
359
+ test ( '.trim modifier should work with v-model on component for kebab-cased props and camelCased emit' , ( ) => {
360
+ const Foo = defineComponent ( {
361
+ render ( ) { } ,
362
+ created ( ) {
363
+ this . $emit ( 'update:firstName' , ' one ' )
364
+ } ,
365
+ } )
366
+
367
+ const fn1 = vi . fn ( )
368
+
369
+ const Comp = ( ) =>
370
+ h ( Foo , {
371
+ 'first-name' : null ,
372
+ 'first-nameModifiers' : { trim : true } ,
373
+ 'onUpdate:first-name' : fn1 ,
374
+ } )
375
+
376
+ render ( h ( Comp ) , nodeOps . createElement ( 'div' ) )
377
+
378
+ expect ( fn1 ) . toHaveBeenCalledTimes ( 1 )
379
+ expect ( fn1 ) . toHaveBeenCalledWith ( 'one' )
380
+ } )
381
+
382
+ test ( '.trim modifier should work with v-model on component for camelCased props and kebab-cased emit' , ( ) => {
383
+ const Foo = defineComponent ( {
384
+ render ( ) { } ,
385
+ created ( ) {
386
+ this . $emit ( 'update:model-value' , ' one ' )
387
+ this . $emit ( 'update:first-name' , ' two ' )
388
+ } ,
389
+ } )
390
+
391
+ const fn1 = vi . fn ( )
392
+ const fn2 = vi . fn ( )
393
+
394
+ const Comp = ( ) =>
395
+ h ( Foo , {
396
+ modelValue : null ,
397
+ modelModifiers : { trim : true } ,
398
+ 'onUpdate:modelValue' : fn1 ,
399
+
400
+ firstName : null ,
401
+ firstNameModifiers : { trim : true } ,
402
+ 'onUpdate:firstName' : fn2 ,
403
+ } )
404
+
405
+ render ( h ( Comp ) , nodeOps . createElement ( 'div' ) )
406
+
407
+ expect ( fn1 ) . toHaveBeenCalledTimes ( 1 )
408
+ expect ( fn1 ) . toHaveBeenCalledWith ( 'one' )
409
+ expect ( fn2 ) . toHaveBeenCalledTimes ( 1 )
410
+ expect ( fn2 ) . toHaveBeenCalledWith ( 'two' )
411
+ } )
412
+
413
+ test ( '.trim modifier should work with v-model on component for mixed cased props and emit' , ( ) => {
414
+ const Foo = defineComponent ( {
415
+ render ( ) { } ,
416
+ created ( ) {
417
+ this . $emit ( 'update:base-URL' , ' one ' )
418
+ } ,
419
+ } )
420
+
421
+ const fn1 = vi . fn ( )
422
+
423
+ const Comp = ( ) =>
424
+ h ( Foo , {
425
+ 'base-URL' : null ,
426
+ 'base-URLModifiers' : { trim : true } ,
427
+ 'onUpdate:base-URL' : fn1 ,
428
+ } )
429
+
430
+ render ( h ( Comp ) , nodeOps . createElement ( 'div' ) )
431
+
432
+ expect ( fn1 ) . toHaveBeenCalledTimes ( 1 )
433
+ expect ( fn1 ) . toHaveBeenCalledWith ( 'one' )
434
+ } )
435
+
359
436
test ( '.trim and .number modifiers should work with v-model on component' , ( ) => {
360
437
const Foo = defineComponent ( {
361
438
render ( ) { } ,
0 commit comments