usercss saving: display errors from mozparser in <pre>

This commit is contained in:
tophf 2017-11-27 06:54:59 +03:00
parent 8d3fd9cc3b
commit 13d7e30a75
2 changed files with 4 additions and 2 deletions

View File

@ -227,7 +227,9 @@ function createSourceEditor(style) {
}));
return;
}
const contents = [String(err)];
const contents = Array.isArray(err) ?
$element({tag: 'pre', textContent: err.join('\n')}) :
[String(err)];
if (Number.isInteger(err.index)) {
const pos = cm.posFromIndex(err.index);
contents[0] += ` (line ${pos.line + 1} col ${pos.ch + 1})`;

View File

@ -165,7 +165,7 @@ function $element(opt) {
const element = ns
? document.createElementNS(ns === 'SVG' || ns === 'svg' ? 'http://www.w3.org/2000/svg' : ns, tag)
: document.createElement(tag || 'div');
const children = opt.appendChild instanceof Array ? opt.appendChild : [opt.appendChild];
const children = Array.isArray(opt.appendChild) ? opt.appendChild : [opt.appendChild];
for (const child of children) {
if (child) {
element.appendChild(child instanceof Node ? child : document.createTextNode(child));