@@ -10,9 +10,13 @@ import {
10
10
onMounted ,
11
11
defineAsyncComponent ,
12
12
defineComponent ,
13
- createTextVNode
13
+ createTextVNode ,
14
+ createVNode ,
15
+ withDirectives ,
16
+ vModelCheckbox
14
17
} from '@vue/runtime-dom'
15
18
import { renderToString , SSRContext } from '@vue/server-renderer'
19
+ import { PatchFlags } from '../../shared/src'
16
20
17
21
function mountWithHydration ( html : string , render : ( ) => any ) {
18
22
const container = document . createElement ( 'div' )
@@ -761,6 +765,36 @@ describe('SSR hydration', () => {
761
765
)
762
766
} )
763
767
768
+ test ( 'force hydrate input v-model with non-string value bindings' , ( ) => {
769
+ const { container } = mountWithHydration (
770
+ '<input type="checkbox" value="true">' ,
771
+ ( ) =>
772
+ withDirectives (
773
+ createVNode (
774
+ 'input' ,
775
+ { type : 'checkbox' , 'true-value' : true } ,
776
+ null ,
777
+ PatchFlags . PROPS ,
778
+ [ 'true-value' ]
779
+ ) ,
780
+ [ [ vModelCheckbox , true ] ]
781
+ )
782
+ )
783
+ expect ( ( container . firstChild as any ) . _trueValue ) . toBe ( true )
784
+ } )
785
+
786
+ test ( 'force hydrate select option with non-string value bindings' , ( ) => {
787
+ const { container } = mountWithHydration (
788
+ '<select><option :value="true">ok</option></select>' ,
789
+ ( ) =>
790
+ h ( 'select' , [
791
+ // hoisted because bound value is a constant...
792
+ createVNode ( 'option' , { value : true } , null , - 1 /* HOISTED */ )
793
+ ] )
794
+ )
795
+ expect ( ( container . firstChild ! . firstChild as any ) . _value ) . toBe ( true )
796
+ } )
797
+
764
798
describe ( 'mismatch handling' , ( ) => {
765
799
test ( 'text node' , ( ) => {
766
800
const { container } = mountWithHydration ( `foo` , ( ) => 'bar' )
0 commit comments