[client/popup] Bugfix: Handle unspecified values

This commit is contained in:
Starbeamrainbowlabs 2019-01-26 11:56:23 +00:00
parent 5934f96aaa
commit 50c500c1ec
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -94,9 +94,18 @@ class LayerDeviceMarkers {
// Filter out properties we're handling specially // Filter out properties we're handling specially
if(["id", "name", "other"].includes(property)) continue; if(["id", "name", "other"].includes(property)) continue;
// Ensure the property is a string - giving special handling to // Ensure the property is a string - giving special handling to
// some property values // some property values
let value = device_info[property]; let value = device_info[property];
// Filter out undefined properties
if(typeof value == "undefined" || value === null) {
value = "(not specified)";
}
// If the value isn't a string, but is still 'truthy'
if(typeof value != "string") { if(typeof value != "string") {
switch(property) { switch(property) {
case "location": case "location":
@ -117,7 +126,7 @@ class LayerDeviceMarkers {
params_container.appendChild(CreateElement("table.device-property-table", ...info_list)); params_container.appendChild(CreateElement("table.device-property-table", ...info_list));
params_container.appendChild(CreateElement("p.device-notes", params_container.appendChild(CreateElement("p.device-notes",
CreateElement("em", device_info.other) CreateElement("em", device_info.other || "")
)); ));
// ---------------------------------- // ----------------------------------