From 92e26cb3d787be12393c1246acb61a84c21e6dee Mon Sep 17 00:00:00 2001 From: gorhill Date: Sat, 7 Feb 2015 15:32:20 -0500 Subject: [PATCH] fixed request count indicators for incrementally built popup --- src/js/popup.js | 25 +++++++++++++++---------- src/popup.html | 6 +++--- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/js/popup.js b/src/js/popup.js index ad5e4be46..d72ff6aee 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -196,27 +196,32 @@ var updateDynamicFilterCell = function(scope, des, type, rule) { } cell.toggleClass('ownRule', ownRule); - if ( scope !== '.' || des === '*' ) { - return; - } - if ( popupData.hostnameDict.hasOwnProperty(des) === false ) { + // IMPORTANT: It is completely assumed the first node is a TEXT_NODE, so + // ensure this in the HTML file counterpart when you make + // changes + var textNode = cell.nodeAt(0).firstChild; + + // Since this may be a cell from a reused row, we need to clear text + // content if we can't compute request counts. + if ( scope !== '.' || des === '*' || popupData.hostnameDict.hasOwnProperty(des) === false ) { + textNode.nodeValue = ' '; return; } + var hnDetails = popupData.hostnameDict[des]; var aCount = hnDetails.allowCount; var bCount = hnDetails.blockCount; if ( aCount === 0 && bCount === 0 ) { + textNode.nodeValue = ' '; return; } + // https://github.com/gorhill/uBlock/issues/471 aCount = Math.min(Math.ceil(Math.log(aCount + 1) / Math.LN10), 3); bCount = Math.min(Math.ceil(Math.log(bCount + 1) / Math.LN10), 3); - // IMPORTANT: It is completely assumed the first node is a TEXT_NODE, so - // ensure this in the HTML file counterpart when you make - // changes - cell.nodeAt(0).firstChild.nodeValue = threePlus.slice(0, aCount) + - sixSpace.slice(aCount + bCount) + - threeMinus.slice(0, bCount); + textNode.nodeValue = threePlus.slice(0, aCount) + + sixSpace.slice(aCount + bCount) + + threeMinus.slice(0, bCount); }; /******************************************************************************/ diff --git a/src/popup.html b/src/popup.html index 07a39d4b5..d2769321e 100644 --- a/src/popup.html +++ b/src/popup.html @@ -28,9 +28,9 @@
-
-
-
+
+
+