diff --git a/snabbdom.js b/snabbdom.js index 6dabbda..a1b2f79 100644 --- a/snabbdom.js +++ b/snabbdom.js @@ -231,7 +231,7 @@ function updateChildren(parentElm, oldCh, newCh) { function patchVnode(oldVnode, newVnode) { var elm = newVnode.elm = oldVnode.elm, pushedSelectors; - pushedSelectors = updateProps(elm, oldVnode, newVnode); + if (!isUndef(newVnode.props)) pushedSelectors = updateProps(elm, oldVnode, newVnode); if (isUndef(newVnode.text)) { updateChildren(elm, oldVnode.children, newVnode.children); } else if (oldVnode.text !== newVnode.text) { diff --git a/test/index.js b/test/index.js index 532fa45..dc58731 100644 --- a/test/index.js +++ b/test/index.js @@ -364,6 +364,14 @@ describe('snabbdom', function() { patch(vnode1, vnode2); assert.deepEqual(map(inner, elm.children), ['Hello', 'World']); }); + it('handles unmoved text nodes', function() { + var vnode1 = h('div', ['Text', h('span', 'Span')]); + var vnode2 = h('div', ['Text', h('span', 'Span')]); + var elm = createElm(vnode1); + assert.equal(elm.childNodes[0].textContent, 'Text'); + patch(vnode1, vnode2); + assert.equal(elm.childNodes[0].textContent, 'Text'); + }); it('prepends element', function() { var vnode1 = h('div', [h('span', 'World')]); var vnode2 = h('div', [h('span', 'Hello'), h('span', 'World')]);