diff --git a/packages/runtime-dom/__tests__/patchProps.spec.ts b/packages/runtime-dom/__tests__/patchProps.spec.ts index 7f418847f..3e7de54a7 100644 --- a/packages/runtime-dom/__tests__/patchProps.spec.ts +++ b/packages/runtime-dom/__tests__/patchProps.spec.ts @@ -152,6 +152,12 @@ describe('runtime-dom: props patching', () => { expect(root.innerHTML).toBe(`
baz
`) }) + test('patch innerHTML porp w/ undefined value', async () => { + const root = document.createElement('div') + render(h('div', { innerHTML: undefined }), root) + expect(root.innerHTML).toBe(`
`) + }) + test('textContent unmount prev children', () => { const fn = vi.fn() const comp = { diff --git a/packages/runtime-dom/src/modules/props.ts b/packages/runtime-dom/src/modules/props.ts index 04f0d0e86..aaacd8197 100644 --- a/packages/runtime-dom/src/modules/props.ts +++ b/packages/runtime-dom/src/modules/props.ts @@ -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 }