File tree 1 file changed +41
-0
lines changed
packages/runtime-dom/__tests__/directives
1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -604,4 +604,45 @@ describe('vModel', () => {
604
604
expect ( foo . selected ) . toEqual ( true )
605
605
expect ( bar . selected ) . toEqual ( true )
606
606
} )
607
+
608
+ it ( 'should work with composition session' , async ( ) => {
609
+ const component = defineComponent ( {
610
+ data ( ) {
611
+ return { value : '' }
612
+ } ,
613
+ render ( ) {
614
+ return [
615
+ withVModel (
616
+ h ( 'input' , {
617
+ 'onUpdate:modelValue' : setValue . bind ( this )
618
+ } ) ,
619
+ this . value
620
+ )
621
+ ]
622
+ }
623
+ } )
624
+ render ( h ( component ) , root )
625
+
626
+ const input = root . querySelector ( 'input' ) !
627
+ const data = root . _vnode . component . data
628
+ expect ( input . value ) . toEqual ( '' )
629
+
630
+ //developer.mozilla.org/en-US/docs/Web/API/Element/compositionstart_event
631
+ //compositionstart event could be fired after a user starts entering a Chinese character using a Pinyin IME
632
+ input . value = '使用拼音'
633
+ triggerEvent ( 'compositionstart' , input )
634
+ await nextTick ( )
635
+ expect ( data . value ) . toEqual ( '' )
636
+
637
+ // input event has no effect during composition session
638
+ input . value = '使用拼音输入'
639
+ triggerEvent ( 'input' , input )
640
+ await nextTick ( )
641
+ expect ( data . value ) . toEqual ( '' )
642
+
643
+ // After compositionend event being fired, an input event will be automatically trigger
644
+ triggerEvent ( 'compositionend' , input )
645
+ await nextTick ( )
646
+ expect ( data . value ) . toEqual ( '使用拼音输入' )
647
+ } )
607
648
} )
You can’t perform that action at this time.
0 commit comments