pull/3/head
paldepind 10 years ago
parent dc0744c57a
commit 95de47368b

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

@ -94,10 +94,10 @@ function init(modules) {
} }
function invokeDestroyHook(vnode) { function invokeDestroyHook(vnode) {
var i = vnode.data.hook, j; var i = vnode.data, j;
if (!isUndef(i) && !isUndef(j = i.destroy)) j(vnode); if (!isUndef(i) && !isUndef(i = i.hook) && !isUndef(i = i.destroy)) i(vnode);
for (i = 0; i < cbs.destroy.length; ++i) cbs.destroy[i](vnode); for (i = 0; i < cbs.destroy.length; ++i) cbs.destroy[i](vnode);
if (!isUndef(vnode.children)) { if (!isUndef(i = vnode.children)) {
for (j = 0; j < vnode.children.length; ++j) { for (j = 0; j < vnode.children.length; ++j) {
invokeDestroyHook(vnode.children[j]); invokeDestroyHook(vnode.children[j]);
} }
@ -112,8 +112,8 @@ function init(modules) {
rm = createRmCb(parentElm, ch.elm, listeners); rm = createRmCb(parentElm, ch.elm, listeners);
for (i = 0; i < cbs.remove.length; ++i) cbs.remove[i](ch, rm); for (i = 0; i < cbs.remove.length; ++i) cbs.remove[i](ch, rm);
invokeDestroyHook(ch); invokeDestroyHook(ch);
if (ch.data.hook && ch.data.hook.remove) { if (!isUndef(i = ch.data) && !isUndef(i = i.hook) && !isUndef(i = i.remove)) {
ch.data.hook.remove(ch, rm); i(ch, rm);
} else { } else {
rm(); rm();
} }

@ -593,6 +593,14 @@ describe('snabbdom', function() {
patch(vnode1, vnode0); patch(vnode1, vnode0);
assert.equal(result.length, 1); assert.equal(result.length, 1);
}); });
it('handles text vnodes with `undefined` `data` property', function() {
var vnode1 = h('div', [
' '
]);
var vnode2 = h('div', []);
patch(vnode0, vnode1);
patch(vnode1, vnode2);
});
it('invokes `destroy` module hook for all removed children', function() { it('invokes `destroy` module hook for all removed children', function() {
var created = 0; var created = 0;
var destroyed = 0; var destroyed = 0;

Loading…
Cancel
Save