diff --git a/packages/runtime-core/__tests__/hydration.spec.ts b/packages/runtime-core/__tests__/hydration.spec.ts index 9e3efdd3f3e..99be4b9c8ab 100644 --- a/packages/runtime-core/__tests__/hydration.spec.ts +++ b/packages/runtime-core/__tests__/hydration.spec.ts @@ -1454,6 +1454,9 @@ describe('SSR hydration', () => { mountWithHydration(``, () => h('textarea', { value: 'foo' }), ) + mountWithHydration(``, () => + h('textarea', { value: '' }), + ) expect(`Hydration attribute mismatch`).not.toHaveBeenWarned() mountWithHydration(`
`, () => h('div', { id: 'foo' })) diff --git a/packages/runtime-core/src/hydration.ts b/packages/runtime-core/src/hydration.ts index 1698204ab62..1436749d1ad 100644 --- a/packages/runtime-core/src/hydration.ts +++ b/packages/runtime-core/src/hydration.ts @@ -739,15 +739,15 @@ function propHasMismatch(el: Element, key: string, clientValue: any): boolean { ) { actual = el.hasAttribute(key) ? el.getAttribute(key) - : el[key as keyof typeof el] + : key in el ? el[key as keyof typeof el] - : false + : '' expected = isBooleanAttr(key) ? includeBooleanAttr(clientValue) ? '' : false : clientValue == null - ? false + ? '' : String(clientValue) if (actual !== expected) { mismatchType = `attribute`