From a3e79151995283ba3dd68cd939e8066c5c48cbd8 Mon Sep 17 00:00:00 2001 From: eight Date: Tue, 25 Sep 2018 21:11:54 +0800 Subject: [PATCH] Fix: use promise API --- background/usercss-helper.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/background/usercss-helper.js b/background/usercss-helper.js index c2f2fe84..32525b28 100644 --- a/background/usercss-helper.js +++ b/background/usercss-helper.js @@ -40,14 +40,13 @@ if (style.usercssData) { return Promise.resolve(style); } - try { - const {sourceCode} = style; - // allow sourceCode to be normalized - delete style.sourceCode; - return Promise.resolve(Object.assign(usercss.buildMeta(sourceCode), style)); - } catch (e) { - return Promise.reject(e); - } + + // allow sourceCode to be normalized + const {sourceCode} = style; + delete style.sourceCode; + + return usercss.buildMeta(sourceCode) + .then(newStyle => Object.assign(newStyle, style)); } function assignVars(style) { @@ -59,7 +58,8 @@ style.id = dup.id; if (style.reason !== 'config') { // preserve style.vars during update - usercss.assignVars(style, dup); + return usercss.assignVars(style, dup) + .then(() => style); } } return style;