From cb5cbb4d10c85624f03c0d6d3bd8f35c55318722 Mon Sep 17 00:00:00 2001 From: eight Date: Sun, 14 Oct 2018 01:39:50 +0800 Subject: [PATCH] Fix: various --- background/usercss-helper.js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/background/usercss-helper.js b/background/usercss-helper.js index ebdd2bf7..850130ee 100644 --- a/background/usercss-helper.js +++ b/background/usercss-helper.js @@ -79,7 +79,7 @@ metaOnly, vars, }) { - return Promise.resolve(usercss.buildMeta(sourceCode)) + return usercss.buildMeta(sourceCode) .then(style => Promise.all([ metaOnly ? style : doBuild(style), @@ -98,31 +98,22 @@ } } - // Parse the source, apply customizations, report fatal/syntax errors + // Build the style within aditional properties then inherit variable values + // from the old style. function parse(style) { - return fetchStyle() + return buildMeta(style) .then(buildMeta) .then(assignVars) .then(usercss.buildCode); - - function fetchStyle() { - // restore if stripped by getStyleWithNoCode - if (typeof style.sourceCode !== 'string') { - return styleManager.get(style.id) - .then(oldStyle => { - style.sourceCode = oldStyle.sourceCode; - return style; - }); - } - return Promise.resolve(style); - } } + // FIXME: simplify this to `installUsercss(sourceCode)`? function installUsercss(style) { return parse(style) .then(styleManager.installStyle); } + // FIXME: simplify this to `editSaveUsercss({sourceCode, exclusions})`? function editSaveUsercss(style) { return parse(style) .then(styleManager.editSave);