Fix: vars could be undefined

This commit is contained in:
eight 2018-09-25 23:21:44 +08:00
parent a7cfeb22e4
commit 29b8f51292
2 changed files with 6 additions and 3 deletions

View File

@ -371,8 +371,11 @@ CodeMirror.hint && (() => {
}
// USO vars in usercss mode editor
const list = Object.keys(editor.getStyle().usercssData.vars)
.filter(name => name.startsWith(leftPart));
const vars = editor.getStyle().usercssData.vars;
const list = vars ?
Object.keys(editor.getStyle().usercssData.vars)
.filter(name => name.startsWith(leftPart)) :
[];
return {
list,
from: {line, ch: prev},

View File

@ -195,7 +195,7 @@ function createStyleElement({style, name}) {
};
}
const parts = createStyleElement.parts;
const configurable = style.usercssData && Object.keys(style.usercssData.vars).length > 0;
const configurable = style.usercssData && style.usercssData.vars && Object.keys(style.usercssData.vars).length > 0;
parts.checker.checked = style.enabled;
parts.nameLink.textContent = tWordBreak(style.name);
parts.nameLink.href = parts.editLink.href = parts.editHrefBase + style.id;