diff --git a/js/usercss.js b/js/usercss.js index 61a7a66b..11e1dac0 100644 --- a/js/usercss.js +++ b/js/usercss.js @@ -579,7 +579,7 @@ var usercss = (() => { worker.instance = new Worker('/vendor-overwrites/csslint/csslint-worker.js'); worker.queue = []; worker.instance.onmessage = ({data}) => { - worker.queue.shift().resolve(data); + worker.queue.shift().resolve(data.__ERROR__ ? Promise.reject(data.__ERROR__) : data); if (worker.queue.length) { worker.instance.postMessage(worker.queue[0].message); } diff --git a/manage/config-dialog.js b/manage/config-dialog.js index ec38aaab..08da4c69 100644 --- a/manage/config-dialog.js +++ b/manage/config-dialog.js @@ -30,11 +30,7 @@ function configDialog(style) { {textContent: t('confirmClose'), dataset: {cmd: 'close'}}, ], onshow, - }).then(() => { - document.body.style.minWidth = ''; - document.body.style.minHeight = ''; - colorpicker.hide(); - }); + }).then(onhide); function getInitialValues(source) { const data = {}; @@ -69,6 +65,12 @@ function configDialog(style) { updateButtons(); } + function onhide() { + document.body.style.minWidth = ''; + document.body.style.minHeight = ''; + colorpicker.hide(); + } + function onchange({target}) { // invoked after element's own onchange so 'va' contains the updated value const va = target.va; @@ -129,6 +131,7 @@ function configDialog(style) { } } if (invalid.length) { + onhide(); messageBox.alert([ $create('div', {style: 'max-width: 34em'}, t('usercssConfigIncomplete')), $create('ol', {style: 'text-align: left'}, @@ -136,11 +139,16 @@ function configDialog(style) { $create({tag: 'li', appendChild: msg}))), ]); } - return numValid && BG.usercssHelper.save(style).then(saved => { - varsInitial = getInitialValues(deepCopy(saved.usercssData.vars)); - vars.forEach(va => onchange({target: va.input})); - updateButtons(); - }); + if (!numValid) { + return; + } + return BG.usercssHelper.save(style) + .then(saved => { + varsInitial = getInitialValues(deepCopy(saved.usercssData.vars)); + vars.forEach(va => onchange({target: va.input})); + updateButtons(); + }) + .catch(errors => onhide() + messageBox.alert(Array.isArray(errors) ? errors.join('\n') : errors)); } function useDefault() { diff --git a/vendor-overwrites/csslint/csslint-worker.js b/vendor-overwrites/csslint/csslint-worker.js index d73479f0..c76ae6cb 100644 --- a/vendor-overwrites/csslint/csslint-worker.js +++ b/vendor-overwrites/csslint/csslint-worker.js @@ -11008,19 +11008,19 @@ self.onmessage = ({data: {action = 'run', code, config}}) => { self.postMessage(CSSLint.getRules().map(rule => JSON.parse(JSON.stringify(rule)))); return; - case 'run': - self.postMessage(CSSLint.verify(code, config).messages.map(m => { - // the functions are non-tranferable and we need only an id - m.rule = {id: m.rule.id}; - return m; - }).filter(m => !m.message.includes('/*[[') && !m.message.includes(']]*/'))); + case 'run': { + const results = CSSLint.verify(code, config).messages + .filter(m => !m.message.includes('/*[[') && !m.message.includes(']]*/')) + .map(m => Object.assign(m, {rule: {id: m.rule.id}})); + self.postMessage(results); return; - + } case 'parse': if (!self.mozParser) { self.importScripts('/js/moz-parser.js'); } mozParser.parse(code) - .then(sections => self.postMessage(sections)); + .then(sections => self.postMessage(sections)) + .catch(info => self.postMessage({__ERROR__: info})); } };