Handle saving styles with undefined applies tos #167
This commit is contained in:
parent
f4d30838f9
commit
7015eb1dc8
4
edit.js
4
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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user