From 412090795718793894a1d83953636cdb626b06a1 Mon Sep 17 00:00:00 2001 From: eight Date: Sun, 25 Nov 2018 21:27:11 +0800 Subject: [PATCH] Fix: failed to find the old style when the name/namespace is changed (#581) --- background/usercss-helper.js | 4 +++- edit/source-editor.js | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/background/usercss-helper.js b/background/usercss-helper.js index f1c6419c..546f1172 100644 --- a/background/usercss-helper.js +++ b/background/usercss-helper.js @@ -75,6 +75,7 @@ * @returns {Promise<{style, dup:Boolean?}>} */ function build({ + styleId, sourceCode, checkDup, metaOnly, @@ -83,7 +84,8 @@ }) { return usercss.buildMeta(sourceCode) .then(style => { - const findDup = checkDup || assignVars ? find(style) : null; + const findDup = checkDup || assignVars ? + find(styleId ? {id: styleId} : style) : Promise.resolve(); return Promise.all([ metaOnly ? style : doBuild(style, findDup), findDup diff --git a/edit/source-editor.js b/edit/source-editor.js index dcd43a13..59209c5b 100644 --- a/edit/source-editor.js +++ b/edit/source-editor.js @@ -82,6 +82,7 @@ function createSourceEditor(style) { function preprocess(style) { return API.buildUsercss({ + styleId: style.id, sourceCode: style.sourceCode, assignVars: true })