Fix: a better way to draw character list?

This commit is contained in:
eight 2018-09-26 11:37:50 +08:00
parent 7b959af3e3
commit d5ee31a080

View File

@ -32,7 +32,7 @@ var usercss = (() => {
return backgroundWorker.parseUsercssMeta(match[0], match.index) return backgroundWorker.parseUsercssMeta(match[0], match.index)
.catch(err => { .catch(err => {
if (err.code) { if (err.code) {
const args = ERR_ARGS_IS_LIST.has(err.code) ? err.args.join(', ') : err.args; const args = ERR_ARGS_IS_LIST.has(err.code) ? drawList(err.args) : err.args;
const message = chrome.i18n.getMessage(`meta_${err.code}`, args); const message = chrome.i18n.getMessage(`meta_${err.code}`, args);
if (message) { if (message) {
err.message = message; err.message = message;
@ -49,6 +49,10 @@ var usercss = (() => {
}); });
} }
function drawList(chars) {
return chars.map(c => c === '"' ? "'\"'" : `"${c}"`).join(', ');
}
/** /**
* @param {Object} style * @param {Object} style
* @param {Boolean} [allowErrors=false] * @param {Boolean} [allowErrors=false]