From a7cfeb22e45e5fb69a06d41ac133262c85ef08a5 Mon Sep 17 00:00:00 2001 From: eight Date: Tue, 25 Sep 2018 22:54:40 +0800 Subject: [PATCH] Fix: window is undefined --- background/background-worker.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/background/background-worker.js b/background/background-worker.js index 2d767962..a1de9e76 100644 --- a/background/background-worker.js +++ b/background/background-worker.js @@ -94,7 +94,7 @@ function getUsercssCompiler(preprocessor) { return new Promise((resolve, reject) => { const varDef = Object.keys(vars).map(key => `${key} = ${vars[key].value};\n`).join(''); if (!Error.captureStackTrace) Error.captureStackTrace = () => {}; - window.stylus(varDef + source).render((err, output) => { + self.stylus(varDef + source).render((err, output) => { if (err) { reject(err); } else { @@ -106,15 +106,15 @@ function getUsercssCompiler(preprocessor) { }, less: { preprocess(source, vars) { - if (!window.less) { - window.less = { + if (!self.less) { + self.less = { logLevel: 0, useFileCache: false, }; } loadScript('/vendor/less/less.min.js'); const varDefs = Object.keys(vars).map(key => `@${key}:${vars[key].value};\n`).join(''); - return window.less.render(varDefs + source) + return self.less.render(varDefs + source) .then(({css}) => css); } },