|
|
@@ -10,9 +10,13 @@ import {
|
|
|
onMounted,
|
|
|
defineAsyncComponent,
|
|
|
defineComponent,
|
|
|
- createTextVNode
|
|
|
+ createTextVNode,
|
|
|
+ createVNode,
|
|
|
+ withDirectives,
|
|
|
+ vModelCheckbox
|
|
|
} from '@vue/runtime-dom'
|
|
|
import { renderToString, SSRContext } from '@vue/server-renderer'
|
|
|
+import { PatchFlags } from '../../shared/src'
|
|
|
|
|
|
function mountWithHydration(html: string, render: () => any) {
|
|
|
const container = document.createElement('div')
|
|
|
@@ -761,6 +765,36 @@ describe('SSR hydration', () => {
|
|
|
)
|
|
|
})
|
|
|
|
|
|
+ test('force hydrate input v-model with non-string value bindings', () => {
|
|
|
+ const { container } = mountWithHydration(
|
|
|
+ '<input type="checkbox" value="true">',
|
|
|
+ () =>
|
|
|
+ withDirectives(
|
|
|
+ createVNode(
|
|
|
+ 'input',
|
|
|
+ { type: 'checkbox', 'true-value': true },
|
|
|
+ null,
|
|
|
+ PatchFlags.PROPS,
|
|
|
+ ['true-value']
|
|
|
+ ),
|
|
|
+ [[vModelCheckbox, true]]
|
|
|
+ )
|
|
|
+ )
|
|
|
+ expect((container.firstChild as any)._trueValue).toBe(true)
|
|
|
+ })
|
|
|
+
|
|
|
+ test('force hydrate select option with non-string value bindings', () => {
|
|
|
+ const { container } = mountWithHydration(
|
|
|
+ '<select><option :value="true">ok</option></select>',
|
|
|
+ () =>
|
|
|
+ h('select', [
|
|
|
+ // hoisted because bound value is a constant...
|
|
|
+ createVNode('option', { value: true }, null, -1 /* HOISTED */)
|
|
|
+ ])
|
|
|
+ )
|
|
|
+ expect((container.firstChild!.firstChild as any)._value).toBe(true)
|
|
|
+ })
|
|
|
+
|
|
|
describe('mismatch handling', () => {
|
|
|
test('text node', () => {
|
|
|
const { container } = mountWithHydration(`foo`, () => 'bar')
|