Passing test "can be replaced and removed" for thunk

pull/56/head
Sylvain Prat 9 years ago
parent df41e1de25
commit 94a3f8767b

@ -27,9 +27,13 @@ function createKeyToOldIdx(children, beginIdx, endIdx) {
return map;
}
function createRmCb(childElm, listeners) {
function createRmCb(child, listeners) {
var elm;
while (isUndef(elm = child.elm)) child = child.data.vnode;
return function() {
if (--listeners === 0) childElm.parentElement.removeChild(childElm);
if (--listeners === 0) {
elm.parentElement.removeChild(elm);
}
};
}
@ -88,15 +92,16 @@ function init(modules) {
}
function invokeDestroyHook(vnode) {
var i = vnode.data, j;
if (isDef(i)) {
if (isDef(i = i.hook) && isDef(i = i.destroy)) i(vnode);
var i, j, data = vnode.data;
if (isDef(data)) {
if (isDef(i = data.hook) && isDef(i = i.destroy)) i(vnode);
for (i = 0; i < cbs.destroy.length; ++i) cbs.destroy[i](vnode);
if (isDef(i = vnode.children)) {
for (j = 0; j < vnode.children.length; ++j) {
invokeDestroyHook(vnode.children[j]);
}
}
if (isDef(i = data.vnode)) invokeDestroyHook(i);
}
}
@ -107,7 +112,7 @@ function init(modules) {
if (isDef(ch.sel)) {
invokeDestroyHook(ch);
listeners = cbs.remove.length + 1;
rm = createRmCb(ch.elm, listeners);
rm = createRmCb(ch, listeners);
for (i = 0; i < cbs.remove.length; ++i) cbs.remove[i](ch, rm);
if (isDef(i = ch.data) && isDef(i = i.hook) && isDef(i = i.remove)) {
i(ch, rm);

Loading…
Cancel
Save