Bug 1368667 - Remove KeyValueTable as it is similar to GenericTable r?chutten
GenericTable expect an array of array as data where KeyValueTable used to expect an object.
Use explodeObject() to process an object so it can be used by GenericTable.
MozReview-Commit-ID: 6hxxFwF2KXg
--- a/toolkit/content/aboutTelemetry.js
+++ b/toolkit/content/aboutTelemetry.js
@@ -1439,82 +1439,16 @@ function RenderObject(aObject) {
}
output = "{\"" + keys[0] + "\":\u00A0" + JSON.stringify(aObject[keys[0]]);
for (let i = 1; i < keys.length; i++) {
output += ", \"" + keys[i] + "\":\u00A0" + JSON.stringify(aObject[keys[i]]);
}
return output + "}";
}
-var KeyValueTable = {
- /**
- * Returns a 2-column table with keys and values
- * @param aMeasurements Each key in this JS object is rendered as a row in
- * the table with its corresponding value
- * @param aKeysLabel Column header for the keys column
- * @param aValuesLabel Column header for the values column
- */
- render: function KeyValueTable_render(aMeasurements, aKeysLabel, aValuesLabel) {
- let table = document.createElement("table");
- this.renderHeader(table, aKeysLabel, aValuesLabel);
- this.renderBody(table, aMeasurements);
- return table;
- },
-
- /**
- * Create the table header
- * Tabs & newlines added to cells to make it easier to copy-paste.
- *
- * @param aTable Table element
- * @param aKeysLabel Column header for the keys column
- * @param aValuesLabel Column header for the values column
- */
- renderHeader: function KeyValueTable_renderHeader(aTable, aKeysLabel, aValuesLabel) {
- let headerRow = document.createElement("tr");
- aTable.appendChild(headerRow);
-
- let keysColumn = document.createElement("th");
- keysColumn.appendChild(document.createTextNode(aKeysLabel + "\t"));
- let valuesColumn = document.createElement("th");
- valuesColumn.appendChild(document.createTextNode(aValuesLabel + "\n"));
-
- headerRow.appendChild(keysColumn);
- headerRow.appendChild(valuesColumn);
- },
-
- /**
- * Create the table body
- * Tabs & newlines added to cells to make it easier to copy-paste.
- *
- * @param aTable Table element
- * @param aMeasurements Key/value map
- */
- renderBody: function KeyValueTable_renderBody(aTable, aMeasurements) {
- for (let [key, value] of Object.entries(aMeasurements)) {
- // use .valueOf() to unbox Number, String, etc. objects
- if (value &&
- (typeof value == "object") &&
- (typeof value.valueOf() == "object")) {
- value = RenderObject(value);
- }
-
- let newRow = document.createElement("tr");
- aTable.appendChild(newRow);
-
- let keyField = document.createElement("td");
- keyField.appendChild(document.createTextNode(key + "\t"));
- newRow.appendChild(keyField);
-
- let valueField = document.createElement("td");
- valueField.appendChild(document.createTextNode(value + "\n"));
- newRow.appendChild(valueField);
- }
- }
-};
-
var GenericTable = {
defaultHeadings: [
bundle.GetStringFromName("keysHeader"),
bundle.GetStringFromName("valuesHeader")
],
/**