Skip to content

Commit

Permalink
fix(hydration): do not warn against bindings array values
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoErii committed Jan 17, 2024
1 parent 07922da commit 4593acc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 7 additions & 0 deletions packages/runtime-core/__tests__/hydration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1531,5 +1531,12 @@ describe('SSR hydration', () => {
mountWithHydration(`<button />`, () => h('button', { href: undefined }))
expect(`Hydration attribute mismatch`).not.toHaveBeenWarned()
})

test('should not warn against array values', () => {
mountWithHydration(`<options value="array" />`, () =>
h('options', { value: ['array'] }),
)
expect(`Hydration attribute mismatch`).not.toHaveBeenWarned()
})
})
})
8 changes: 5 additions & 3 deletions packages/runtime-core/src/hydration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import {
isBooleanAttr,
isKnownHtmlAttr,
isKnownSvgAttr,
isObject,
isOn,
isPlainObject,
isReservedProp,
isString,
normalizeClass,
Expand Down Expand Up @@ -768,12 +768,14 @@ function propHasMismatch(
// #10000 some attrs such as textarea.value can't be retrieved by `hasAttribute`
const serverValue = el[key as keyof typeof el]
actual =
isObject(serverValue) || serverValue == null
isPlainObject(serverValue) || serverValue == null
? ''
: String(serverValue)
}
expected =
isObject(clientValue) || clientValue == null ? '' : String(clientValue)
isPlainObject(clientValue) || clientValue == null
? ''
: String(clientValue)
}
if (actual !== expected) {
mismatchType = `attribute`
Expand Down

0 comments on commit 4593acc

Please sign in to comment.