Skip to content

Commit 5df67e3

Browse files
authoredJul 19, 2024··
fix(runtime-dom): handle undefined values in v-html (#11403)
1 parent c7f5c70 commit 5df67e3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
 

‎packages/runtime-dom/__tests__/patchProps.spec.ts

+6
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ describe('runtime-dom: props patching', () => {
152152
expect(root.innerHTML).toBe(`<div><del>baz</del></div>`)
153153
})
154154

155+
test('patch innerHTML porp w/ undefined value', async () => {
156+
const root = document.createElement('div')
157+
render(h('div', { innerHTML: undefined }), root)
158+
expect(root.innerHTML).toBe(`<div></div>`)
159+
})
160+
155161
test('textContent unmount prev children', () => {
156162
const fn = vi.fn()
157163
const comp = {

‎packages/runtime-dom/src/modules/props.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function patchDOMProp(
1515
if (key === 'innerHTML' || key === 'textContent') {
1616
// null value case is handled in renderer patchElement before patching
1717
// children
18-
if (value === null) return
18+
if (value == null) return
1919
el[key] = value
2020
return
2121
}

0 commit comments

Comments
 (0)
Please sign in to comment.