code review

This commit is contained in:
gorhill 2015-06-27 16:18:29 -04:00
parent f988d74b4d
commit 58b6552207
1 changed files with 11 additions and 1 deletions

View File

@ -236,10 +236,14 @@ var tabIdFromClassName = function(className) {
var patchCosmeticHide = delta >= 0 &&
from.classList.contains('isCosmeticFilter') &&
li.classList.contains('hasCosmeticFilter') === false;
// Include descendants count when removing a node
if ( delta < 0 ) {
delta -= countFromNode(from);
}
for ( ; li.localName === 'li'; li = li.parentElement.parentElement ) {
span = li.children[2];
if ( delta !== 0 ) {
cnt = parseInt(span.getAttribute('data-cnt'), 10) + delta;
cnt = countFromNode(li) + delta;
span.textContent = cnt !== 0 ? cnt.toLocaleString() : '';
span.setAttribute('data-cnt', cnt);
}
@ -309,6 +313,12 @@ var tabIdFromClassName = function(className) {
}
};
var countFromNode = function(li) {
var span = li.children[2];
var cnt = parseInt(span.getAttribute('data-cnt'), 10);
return isNaN(cnt) ? cnt : 0;
};
var selectorFromNode = function(node, nth) {
var selector = '';
var code;