Skip to content

Commit d0afcd3

Browse files
committed
fix domProps unset for v-html (fix #4107)
1 parent fa16b12 commit d0afcd3

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/core/vdom/patch.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ export function createPatchFunction (backend) {
7878

7979
function removeElement (el) {
8080
const parent = nodeOps.parentNode(el)
81-
nodeOps.removeChild(parent, el)
81+
// element may have already been removed due to v-html
82+
if (parent) {
83+
nodeOps.removeChild(parent, el)
84+
}
8285
}
8386

8487
function createElm (vnode, insertedVnodeQueue, nested) {

src/platforms/web/runtime/modules/dom-props.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function updateDOMProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {
1717

1818
for (key in oldProps) {
1919
if (props[key] == null) {
20-
elm[key] = undefined
20+
elm[key] = ''
2121
}
2222
}
2323
for (key in props) {

test/unit/modules/vdom/modules/dom-props.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('vdom domProps module', () => {
2222
const vnode2 = new VNode('a', { domProps: {}})
2323
patch(null, vnode1)
2424
const elm = patch(vnode1, vnode2)
25-
expect(elm.src).toBeUndefined()
25+
expect(elm.src).toBe('')
2626
})
2727

2828
it('should initialize the elements value to zero', () => {

0 commit comments

Comments
 (0)