diff --git a/edit/source-editor.js b/edit/source-editor.js index ef7754ab..4e98de38 100644 --- a/edit/source-editor.js +++ b/edit/source-editor.js @@ -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})`; diff --git a/js/dom.js b/js/dom.js index aeb1bb95..bd22bb5c 100644 --- a/js/dom.js +++ b/js/dom.js @@ -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));