diff --git a/common/content/commandline.js b/common/content/commandline.js
index 24c834bb..4b0d104e 100644
--- a/common/content/commandline.js
+++ b/common/content/commandline.js
@@ -1397,8 +1397,8 @@ var CommandLine = Module("commandline", {
substring = substring.substr(value.length);
this.removeSubstring = substring;
- let node = DOM.fromXML({substring},
- document);
+ let node = DOM.fromJSON(["span", { highlight: "Preview" }, substring],
+ document);
this.withSavedValues(["caret"], function () {
this.editor.insertNode(node, this.editor.rootElement, 1);
@@ -1889,19 +1889,18 @@ var ItemList = Class("ItemList", {
DOM(this.win).resize(this._onResize.closure.tell);
},
- get rootXML()
-
-
-
{_("completion.noCompletions")}
-
-
+ get rootXML()
+ ["div", { highlight: "Normal", style: "white-space: nowrap", key: "root" },
+ ["div", { key: "wrapper" },
+ ["div", { highlight: "Completions", key: "noCompletions" },
+ ["span", { highlight: "Title" },
+ _("completion.noCompletions")]],
+ ["div", { key: "completions" }]],
-
{
- template.map(util.range(0, options["maxitems"] * 2), function (i)
-
~)
- }
-
- .elements(),
+ ["div", { highlight: "Completions" },
+ template_.map(util.range(0, options["maxitems"] * 2), function (i)
+ ["div", { highlight: "CompItem NonText" },
+ "~"])]],
get itemCount() this.context.contextList.reduce(function (acc, ctxt) acc + ctxt.items.length, 0),
@@ -2225,21 +2224,19 @@ var ItemList = Class("ItemList", {
},
get rootXML()
-
-
- { this.context.createRow(this.context.title || [], "CompTitle") }
-
-
-
-
-
{this.context.message}
-
-
{ItemList.WAITING_MESSAGE}
-
-
-
,
+ ["div", { key: "root", highlight: "CompGroup" },
+ ["div", { highlight: "Completions" },
+ this.context.createRow(this.context.title || [], "CompTitle")],
+ ["div", { highlight: "CompTitleSep" }],
+ ["div", { key: "contents" },
+ ["div", { key: "up", highlight: "CompLess" }],
+ ["div", { key: "message", highlight: "CompMsg" },
+ this.context.message || []],
+ ["div", { key: "itemsContainer", class: "completion-items-container" },
+ ["div", { key: "items", highlight: "Completions" }]],
+ ["div", { key: "waiting", highlight: "CompMsg" },
+ ItemList.WAITING_MESSAGE],
+ ["div", { key: "down", highlight: "CompMore" }]]],
get doc() this.parent.doc,
get win() this.parent.win,
@@ -2281,7 +2278,7 @@ var ItemList = Class("ItemList", {
this.nodes = {};
this.generatedRange = ItemList.Range(0, 0);
- DOM.fromXML(this.rootXML, this.doc, this.nodes);
+ DOM.fromJSON(this.rootXML, this.doc, this.nodes);
},
/**
@@ -2292,7 +2289,8 @@ var ItemList = Class("ItemList", {
DOM(this.nodes.items).empty();
if (this.context.message)
- DOM(this.nodes.message).empty().append(<>{this.context.message}>);
+ DOM(this.nodes.message).empty()
+ .append(DOM.fromJSON(this.context.message, this.doc));
if (!this.selectedIdx > this.itemCount)
this.selectedIdx = null;
diff --git a/common/modules/javascript.jsm b/common/modules/javascript.jsm
index 32af91b9..bf0d9fe3 100644
--- a/common/modules/javascript.jsm
+++ b/common/modules/javascript.jsm
@@ -2,7 +2,7 @@
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
-/* use strict */
+"use strict";
let { getOwnPropertyNames } = Object;
@@ -13,7 +13,7 @@ defineModule("javascript", {
require: ["util"]
});
-lazyRequire("template", ["template"]);
+lazyRequire("template", ["template", "template_"]);
let isPrototypeOf = Object.prototype.isPrototypeOf;
@@ -489,10 +489,10 @@ var JavaScript = Module("javascript", {
if (callable(func)) {
let [, prefix, args] = /^(function .*?)\((.*?)\)/.exec(Function.prototype.toString.call(func));
let n = this._get(i).comma.length;
- args = template.map(Iterator(args.split(", ")),
- function ([i, arg]) {arg},
- <>, >);
- this.context.message = <>{prefix}({args})>;
+ args = template_.map(Iterator(args.split(", ")),
+ function ([i, arg]) ["span", { highlight: i == n ? "Filter" : "" }, arg],
+ ",\u00a0");
+ this.context.message = ["", prefix + "(", args, ")"];
}
}
}
@@ -596,8 +596,8 @@ var JavaScript = Module("javascript", {
if (!this.context.tabPressed && key == "" && obj.length > 1) {
let message = this.context.message || "";
this.context.waitingForTab = true;
- this.context.message = <>{message}
- {_("completion.waitingForKeyPress")}>;
+ this.context.message = ["", message, "\n",
+ _("completion.waitingForKeyPress")];
return null;
}
@@ -716,7 +716,6 @@ var JavaScript = Module("javascript", {
},
addOutput: function addOutput(js) {
- default xml namespace = XHTML;
this.count++;
try {
@@ -729,19 +728,21 @@ var JavaScript = Module("javascript", {
if (e.fileName)
e = util.fixURI(e.fileName) + ":" + e.lineNumber + ": " + e;
- xml = {e};
+ xml = ["span", { highlight: "ErrorMsg" }, e];
}
let prompt = "js" + this.count;
Class.replaceProperty(this.context, prompt, result);
- XML.ignoreWhitespace = XML.prettyPrinting = false;
let nodes = {};
this.rootNode.appendChild(
- util.xmlToDom(
- {prompt}> {js}
- {xml}
- .elements(), this.document, nodes));
+ DOM.fromJSON(
+ [["div", { highlight: "REPL-E", key: "e" },
+ ["span", { highlight: "REPL-R" },
+ prompt, ">"], " ", js],
+ ["div", { highlight: "REPL-P", key: "p" },
+ xml]],
+ this.document, nodes));
this.rootNode.scrollTop += nodes.e.getBoundingClientRect().top
- this.rootNode.getBoundingClientRect().top;
@@ -750,7 +751,6 @@ var JavaScript = Module("javascript", {
count: 0,
message: Class.Memoize(function () {
- default xml namespace = XHTML;
DOM.fromJSON(["div", { highlight: "REPL", key: "rootNode" }],
this.document, this);
diff --git a/common/modules/util.jsm b/common/modules/util.jsm
index 288c30c4..5981ac02 100644
--- a/common/modules/util.jsm
+++ b/common/modules/util.jsm
@@ -1024,7 +1024,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
return color ? {string}
: [s for each (s in string)].join("");
},
- prettifyJSON: function prettifyJSON(data, indent) {
+ prettifyJSON: function prettifyJSON(data, indent, invalidOK) {
const INDENT = indent || " ";
function rec(data, level, seen) {
@@ -1072,6 +1072,8 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
else
res[res.length - 1] = "{}";
}
+ else if (invalidOK)
+ res.push({}.toString.call(data));
else
throw Error("Invalid JSON object");
}