Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions packages/runtime-core/__tests__/hydration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,30 @@ describe('SSR hydration', () => {
expect((container.firstChild!.firstChild as any)._value).toBe(true)
})

test('force hydrate prop with `.prop` modifier', () => {
const { container } = mountWithHydration(
'<input type="checkbox" :indeterminate.prop="true">',
() =>
h('input', {
type: 'checkbox',
'.indeterminate': true
})
)
expect((container.firstChild! as any).indeterminate).toBe(true)
})

test('force hydrate prop with `.attr` modifier', () => {
const { container } = mountWithHydration(
'<input type="checkbox" :x.attr="1">',
() =>
h('input', {
type: 'checkbox',
'^x': 1
})
)
expect((container.firstChild! as any).getAttribute('x')).toBe('1')
})

// #5728
test('empty text node in slot', () => {
const Comp = {
Expand Down
5 changes: 4 additions & 1 deletion packages/runtime-core/src/hydration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,10 @@ export function createHydrationFunctions(
for (const key in props) {
if (
(forcePatchValue && key.endsWith('value')) ||
(isOn(key) && !isReservedProp(key))
(isOn(key) && !isReservedProp(key)) ||
// support .prop & .attr modifiers
key[0] === '.' ||
key[0] === '^'
) {
patchProp(
el,
Expand Down