mirror of https://github.com/vuejs/core.git
fix(hydration): improve mismatch when client valut is null or undefined (#10086)
This commit is contained in:
parent
bb6b7a297e
commit
08b60f5d0d
|
@ -1512,6 +1512,16 @@ describe('SSR hydration', () => {
|
|||
expect(`Hydration attribute mismatch`).not.toHaveBeenWarned()
|
||||
})
|
||||
|
||||
test('client value is null or undefined', () => {
|
||||
mountWithHydration(`<div></div>`, () =>
|
||||
h('div', { draggable: undefined }),
|
||||
)
|
||||
expect(`Hydration attribute mismatch`).not.toHaveBeenWarned()
|
||||
|
||||
mountWithHydration(`<input />`, () => h('input', { type: null }))
|
||||
expect(`Hydration attribute mismatch`).not.toHaveBeenWarned()
|
||||
})
|
||||
|
||||
test('should not warn against object values', () => {
|
||||
mountWithHydration(`<input />`, () => h('input', { from: {} }))
|
||||
expect(`Hydration attribute mismatch`).not.toHaveBeenWarned()
|
||||
|
|
|
@ -758,6 +758,9 @@ function propHasMismatch(
|
|||
if (isBooleanAttr(key)) {
|
||||
actual = el.hasAttribute(key)
|
||||
expected = includeBooleanAttr(clientValue)
|
||||
} else if (clientValue == null) {
|
||||
actual = el.hasAttribute(key)
|
||||
expected = false
|
||||
} else {
|
||||
if (el.hasAttribute(key)) {
|
||||
actual = el.getAttribute(key)
|
||||
|
|
Loading…
Reference in New Issue