From 13d7e30a75c27a69e37891f2d2c44416df7d603e Mon Sep 17 00:00:00 2001 From: tophf Date: Mon, 27 Nov 2017 06:54:59 +0300 Subject: [PATCH] usercss saving: display errors from mozparser in

---
 edit/source-editor.js | 4 +++-
 js/dom.js             | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

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));