fix(runtime-dom): handle undefined values in v-html (#11403)

This commit is contained in:
Tycho 2024-07-19 16:52:03 +08:00 committed by GitHub
parent c7f5c70eba
commit 5df67e3675
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View File

@ -152,6 +152,12 @@ describe('runtime-dom: props patching', () => {
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', () => {
const fn = vi.fn()
const comp = {

View File

@ -15,7 +15,7 @@ export function patchDOMProp(
if (key === 'innerHTML' || key === 'textContent') {
// null value case is handled in renderer patchElement before patching
// children
if (value === null) return
if (value == null) return
el[key] = value
return
}