Fix bug with properties being updated on text nodes

pull/2/head
paldepind 10 years ago
parent 92c41b9b9c
commit 1c509cd653

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

@ -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')]);

Loading…
Cancel
Save