Browse Source

fix domProps unset for v-html (fix #4107)

dev
Evan You 8 years ago
parent
commit
d0afcd3cf9
  1. 5
      src/core/vdom/patch.js
  2. 2
      src/platforms/web/runtime/modules/dom-props.js
  3. 2
      test/unit/modules/vdom/modules/dom-props.spec.js

5
src/core/vdom/patch.js

@ -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) {

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

@ -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) {

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

@ -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', () => {

Loading…
Cancel
Save