fix(runtime-dom): handle undefined values in v-html (#11403)
This commit is contained in:
parent
c7f5c70eba
commit
5df67e3675
|
@ -152,6 +152,12 @@ describe('runtime-dom: props patching', () => {
|
||||||
expect(root.innerHTML).toBe(`<div><del>baz</del></div>`)
|
expect(root.innerHTML).toBe(`<div><del>baz</del></div>`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('patch innerHTML porp w/ undefined value', async () => {
|
||||||
|
const root = document.createElement('div')
|
||||||
|
render(h('div', { innerHTML: undefined }), root)
|
||||||
|
expect(root.innerHTML).toBe(`<div></div>`)
|
||||||
|
})
|
||||||
|
|
||||||
test('textContent unmount prev children', () => {
|
test('textContent unmount prev children', () => {
|
||||||
const fn = vi.fn()
|
const fn = vi.fn()
|
||||||
const comp = {
|
const comp = {
|
||||||
|
|
|
@ -15,7 +15,7 @@ export function patchDOMProp(
|
||||||
if (key === 'innerHTML' || key === 'textContent') {
|
if (key === 'innerHTML' || key === 'textContent') {
|
||||||
// null value case is handled in renderer patchElement before patching
|
// null value case is handled in renderer patchElement before patching
|
||||||
// children
|
// children
|
||||||
if (value === null) return
|
if (value == null) return
|
||||||
el[key] = value
|
el[key] = value
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue