]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(hydration): should not warn mismatch for nullish prop
authorEvan You <yyx990803@gmail.com>
Tue, 12 Dec 2023 18:41:49 +0000 (02:41 +0800)
committerEvan You <yyx990803@gmail.com>
Tue, 12 Dec 2023 18:41:49 +0000 (02:41 +0800)
packages/runtime-core/__tests__/hydration.spec.ts
packages/runtime-core/src/hydration.ts

index 0805d5e3f13503b596598d470a5b42b92adb7592..d051c6da4a4ac67073e22399b93c1b0fbda6bcd7 100644 (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 })
index c3fba6cc486494b2356cc928f1b02a189a5bcf3f..b873a37dc0631c8b49392d685c21346c74f0e688 100644 (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