Fix bug regarding changed text nodes

pull/3/head
paldepind 10 years ago
parent cd7eb76a09
commit b4b90ac609

@ -1,6 +1,6 @@
{
"name": "snabbdom",
"version": "0.1.2",
"version": "0.1.3",
"description": "A virtual DOM library with focus on simplicity, modularity, powerful features and performance.",
"main": "snabbdom.js",
"directories": {

@ -193,7 +193,7 @@ function init(modules) {
removeVnodes(elm, oldCh, 0, oldCh.length - 1);
}
} else if (oldVnode.text !== vnode.text) {
elm.childNodes[0].nodeValue = vnode.text;
elm.textContent = vnode.text;
}
return vnode;
}

@ -360,6 +360,14 @@ describe('snabbdom', function() {
patch(vnode1, vnode2);
assert.equal(elm.childNodes[0].textContent, 'Text');
});
it('handles changing text children', function() {
var vnode1 = h('div', ['Text', h('span', 'Span')]);
var vnode2 = h('div', ['Text2', h('span', 'Span')]);
patch(vnode0, vnode1);
assert.equal(elm.childNodes[0].textContent, 'Text');
patch(vnode1, vnode2);
assert.equal(elm.childNodes[0].textContent, 'Text2');
});
it('prepends element', function() {
var vnode1 = h('div', [h('span', 'World')]);
var vnode2 = h('div', [h('span', 'Hello'), h('span', 'World')]);

Loading…
Cancel
Save