fix(hydration): should not warn mismatch for nullish prop

This commit is contained in:
Evan You 2023-12-13 02:41:49 +08:00
parent 0b6effb423
commit 33159a5916
2 changed files with 4 additions and 1 deletions

View File

@ -1397,6 +1397,7 @@ describe('SSR hydration', () => {
mountWithHydration(`<div spellcheck></div>`, () =>
h('div', { spellcheck: '' })
)
mountWithHydration(`<div></div>`, () => h('div', { id: undefined }))
// boolean
mountWithHydration(`<select multiple></div>`, () =>
h('select', { multiple: true })

View File

@ -740,7 +740,9 @@ function propHasMismatch(el: Element, key: string, clientValue: any): boolean {
? includeBooleanAttr(clientValue)
? ''
: false
: String(clientValue)
: clientValue == null
? false
: String(clientValue)
if (actual !== expected) {
mismatchType = `attribute`
mismatchKey = key