From 29b8f512926b1f772fad26182748c4471cc19f7d Mon Sep 17 00:00:00 2001 From: eight Date: Tue, 25 Sep 2018 23:21:44 +0800 Subject: [PATCH] Fix: vars could be undefined --- edit/codemirror-default.js | 7 +++++-- manage/manage.js | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/edit/codemirror-default.js b/edit/codemirror-default.js index 0912f445..74fc2942 100644 --- a/edit/codemirror-default.js +++ b/edit/codemirror-default.js @@ -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}, diff --git a/manage/manage.js b/manage/manage.js index 01b005f8..e9a8dd56 100644 --- a/manage/manage.js +++ b/manage/manage.js @@ -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;