Skip to content

Commit

Permalink
fix domProps unset for v-html (fix #4107)
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Nov 4, 2016
1 parent fa16b12 commit d0afcd3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/core/vdom/patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ export function createPatchFunction (backend) {

function removeElement (el) {
const parent = nodeOps.parentNode(el)
nodeOps.removeChild(parent, el)
// element may have already been removed due to v-html
if (parent) {
nodeOps.removeChild(parent, el)
}
}

function createElm (vnode, insertedVnodeQueue, nested) {
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/web/runtime/modules/dom-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function updateDOMProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {

for (key in oldProps) {
if (props[key] == null) {
elm[key] = undefined
elm[key] = ''
}
}
for (key in props) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/modules/vdom/modules/dom-props.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('vdom domProps module', () => {
const vnode2 = new VNode('a', { domProps: {}})
patch(null, vnode1)
const elm = patch(vnode1, vnode2)
expect(elm.src).toBeUndefined()
expect(elm.src).toBe('')
})

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

0 comments on commit d0afcd3

Please sign in to comment.