Commit 2cbd494d by Thimo Kraemer

Fixed logging of cleaned nodes

parent 98150a24
......@@ -238,39 +238,40 @@ kss._observe = function(records, observer) {
kss._cleanNode = function(node, deep) {
var count = 0;
if (deep) {
count += kss._cleanChildNodes(node);
}
node.removeAttribute('data-has-kss');
var kssId = node._kssId;
if (!kssId)
return count;
kss.each(node._kssEvtHandlers, function(hnd) {
node.removeEventListener(hnd.eventname, hnd);
hnd.node = null;
});
kss.each(node._kssEvtBinders, function(bnd) {
if (bnd.destroy) {
try { bnd.destroy(); }
catch (err) { kss.error(err); }
}
});
delete node._kssEvtHandlers;
delete node._kssEvtBinders;
delete node._kssRules;
delete node._kssId;
delete kss._nodeRegister[kssId];
count++;
deep && kss.log('Cleand up ' + count + ' node(s)');
if (kssId) {
kss.each(node._kssEvtHandlers, function(hnd) {
node.removeEventListener(hnd.eventname, hnd);
hnd.node = null;
});
kss.each(node._kssEvtBinders, function(bnd) {
if (bnd.destroy) {
try { bnd.destroy(); }
catch (err) { kss.error(err); }
}
});
delete node._kssEvtHandlers;
delete node._kssEvtBinders;
delete node._kssRules;
delete node._kssId;
delete kss._nodeRegister[kssId];
count = 1;
}
if (deep) {
count = kss._cleanChildNodes(node, count);
}
return count;
};
kss._cleanChildNodes = function(node) {
kss._cleanChildNodes = function(node, _count) {
_count = _count || 0;
var nodes = kss.cssQuery('*[data-has-kss]', node);
kss.each(nodes, function(node) {
kss._cleanNode(node);
_count += kss._cleanNode(node);
});
return nodes.length;
_count && kss.log('Cleaned up ' + _count + ' node(s)');
return _count;
};
kss._cleanUp = function(purgeAll) {
......@@ -282,7 +283,7 @@ kss._cleanUp = function(purgeAll) {
count++;
}
});
count && kss.log('Cleand up ' + count + ' node(s)');
count && kss.log('Cleaned up ' + count + ' node(s)');
};
kss._register = function(name, func, what, many) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment