diff --git a/edit.js b/edit.js index 230586d9..d05e43a7 100644 --- a/edit.js +++ b/edit.js @@ -1265,7 +1265,7 @@ function getSectionsHashes() { } function getMeta(e) { - var meta = {}; + var meta = {urls: [], urlPrefixes: [], domains: [], regexps: []}; e.querySelector(".applies-to-list").childNodes.forEach(function(li) { if (li.className == template.appliesToEverything.className) { return; @@ -1274,7 +1274,7 @@ function getMeta(e) { var value = li.querySelector("[name=applies-value]").value; if (type && value) { var property = CssToProperty[type]; - meta[property] ? meta[property].push(value) : meta[property] = [value]; + meta[property].push(value); } }); return meta; diff --git a/storage.js b/storage.js index 03f4154e..5cd345ee 100644 --- a/storage.js +++ b/storage.js @@ -105,6 +105,14 @@ function saveStyle(o, callback) { }).forEach(function(att) { o[att] = null; }); + // Set other optional things to empty array if they're undefined + o.sections.forEach(function(section) { + ["urls", "urlPrefixes", "domains", "regexps"].forEach(function(property) { + if (!section[property]) { + section[property] = []; + } + }); + }); // Set to enabled if not set if (!("enabled" in o)) { o.enabled = true;