Bug 1389165 - Hide caption when no data for table in about:telemetry r=chutten
authorflyingrub <flyinggrub@gmail.com>
Fri, 11 Aug 2017 11:27:12 +0200
changeset 647024 850ff7976b8df05512722aa8942ff050cc054671
parent 647023 3b5f1b11db0ebd0b914c42eff7dbf44ab47cf638
child 647025 6e599cdfa3fbe50c2ec3f2d17e3c419f5a3eea04
push id74288
push userhikezoe@mozilla.com
push dateWed, 16 Aug 2017 00:19:57 +0000
reviewerschutten
bugs1389165
milestone57.0a1
Bug 1389165 - Hide caption when no data for table in about:telemetry r=chutten MozReview-Commit-ID: 7wO2VisFyzI
toolkit/content/aboutTelemetry.js
--- a/toolkit/content/aboutTelemetry.js
+++ b/toolkit/content/aboutTelemetry.js
@@ -1413,22 +1413,27 @@ var Search = {
         };
       }
     }
     return [isPassFunc, filter]
   },
 
   filterElements(elements, filterText) {
     let [isPassFunc, filter] = this.chooseFilter(filterText);
+    let allElementHidden = true;
 
     let needLowerCase = (isPassFunc === this.isPassText);
     for (let element of elements) {
       let subject = needLowerCase ? element.id.toLowerCase() : element.id;
       element.hidden = !isPassFunc(subject, filter);
+      if (allElementHidden && !element.hidden) {
+        allElementHidden = false;
+      }
     }
+    return allElementHidden;
   },
 
   filterKeyedElements(keyedElements, filterText) {
     let [isPassFunc, filter] = this.chooseFilter(filterText);
 
     let needLowerCase = (isPassFunc === this.isPassText);
     keyedElements.forEach((keyedElement) => {
       let subject = needLowerCase ? keyedElement.key.id.toLowerCase() : keyedElement.key.id;
@@ -1486,17 +1491,20 @@ var Search = {
       for (let key of threads) {
         let datas = key.getElementsByClassName("histogram");
         keyedElements.push({key, datas});
       }
       this.filterKeyedElements(keyedElements, text);
     } else {
       let tables = selectedSection.querySelectorAll("table");
       for (let table of tables) {
-        this.filterElements(table.rows, text);
+        let allElementsHidden = this.filterElements(table.rows, text);
+        if (table.caption) {
+          table.caption.hidden = allElementsHidden;
+        }
       }
     }
   },
 }
 
 /*
  * Helper function to render JS objects with white space between top level elements
  * so that they look better in the browser