From 619b89e6a66e07ef9f68bc06bb1acb4f28c5f55b Mon Sep 17 00:00:00 2001 From: gorhill Date: Thu, 1 Jan 2015 07:29:28 -0500 Subject: [PATCH] avoid dom changes if possible --- src/js/popup.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/js/popup.js b/src/js/popup.js index 0504196a8..91dab68e2 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -173,8 +173,13 @@ var syncDynamicFilterCell = function(scope, des, type, result) { return; } var hnDetails = stats.hostnameDict[des]; - var aCount = Math.min(Math.ceil(Math.log10(hnDetails.allowCount + 1)), 3); - var bCount = Math.min(Math.ceil(Math.log10(hnDetails.blockCount + 1)), 3); + var aCount = hnDetails.allowCount; + var bCount = hnDetails.blockCount; + if ( aCount === 0 && bCount === 0 ) { + return; + } + aCount = Math.min(Math.ceil(Math.log10(aCount + 1)), 3); + bCount = Math.min(Math.ceil(Math.log10(bCount + 1)), 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 @@ -279,7 +284,9 @@ var renderPopup = function(details) { ); } - syncAllDynamicFilters(); + //if ( stats.dynamicFilteringEnabled ) { + syncAllDynamicFilters(); + //} uDom('#total-blocked').html(html.join('')); uDom('#switch .fa').toggleClass('off', stats.pageURL === '' || !stats.netFilteringSwitch);