From 9c1dc28cc9d8c0908ac986427ff37c65ed1eb93f Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Wed, 28 Nov 2012 00:03:42 -0800 Subject: [PATCH] Death to E4X and stuff. --- common/modules/addons.jsm | 63 +++++++++++++++++++-------------------- common/modules/dom.jsm | 13 ++++---- 2 files changed, 36 insertions(+), 40 deletions(-) diff --git a/common/modules/addons.jsm b/common/modules/addons.jsm index f2c16f24..cc5b805b 100644 --- a/common/modules/addons.jsm +++ b/common/modules/addons.jsm @@ -3,7 +3,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"; try { @@ -146,21 +146,18 @@ var Addon = Class("Addon", { this.nodes = { commandTarget: this }; - XML.ignoreWhitespace = true; - util.xmlToDom( - - - - - {_("addon.action.On")} - {_("addon.action.Off")} - {_("addon.action.Delete")} - {_("addon.action.Update")} - {_("addon.action.Options")} - - - - , + DOM.fromJSON( + ["tr", { highlight: "Addon", key: "row" }, + ["td", { highlight: "AddonName", key: "name" }], + ["td", { highlight: "AddonVersion", key: "version" }], + ["td", { highlight: "AddonButtons Buttons" }, + ["a", { highlight: "Button", href: "javascript:0", key: "enable" }, _("addon.action.On")], + ["a", { highlight: "Button", href: "javascript:0", key: "disable" }, _("addon.action.Off")], + ["a", { highlight: "Button", href: "javascript:0", key: "delete" }, _("addon.action.Delete")], + ["a", { highlight: "Button", href: "javascript:0", key: "update" }, _("addon.action.Update")], + ["a", { highlight: "Button", href: "javascript:0", key: "options" }, _("addon.action.Options")]], + ["td", { highlight: "AddonStatus", key: "status" }], + ["td", { highlight: "AddonDescription", key: "description" }]], this.list.document, this.nodes); this.update(); @@ -190,11 +187,8 @@ var Addon = Class("Addon", { compare: function compare(other) String.localeCompare(this.name, other.name), get statusInfo() { - XML.ignoreWhitespace = XML.prettyPrinting = false; - default xml namespace = XHTML; - - let info = this.isActive ? enabled - : disabled; + let info = this.isActive ? ["span", { highlight: "Enabled" }, "enabled"] + : ["span", { highlight: "Disabled" }, "disabled"]; let pending; if (this.pendingOperations & AddonManager.PENDING_UNINSTALL) @@ -208,8 +202,11 @@ var Addon = Class("Addon", { else if (this.pendingOperations & AddonManager.PENDING_UPGRADE) pending = ["Enabled", "upgraded"]; if (pending) - return <>{info} ({pending[1]} -  on restart); + return [info, " (", + ["span", { highlight: pending[0] }, pending[1]], + " on ", + ["a", { href: "#", "dactyl:command": "dactyl.restart" }, "restart"], + ")"] return info; }, @@ -219,7 +216,8 @@ var Addon = Class("Addon", { let node = self.nodes[key]; while (node.firstChild) node.removeChild(node.firstChild); - node.appendChild(util.xmlToDom(<>{xml}, self.list.document)); + + DOM(node).append(isArray(xml) || isXML(xml) ? xml : DOM.DOMString(xml)); } update("name", template.icon({ icon: this.iconURL }, this.name)); @@ -283,15 +281,14 @@ var AddonList = Class("AddonList", { message: Class.Memoize(function () { XML.ignoreWhitespace = true; - util.xmlToDom( - - - - - - -
{_("title.Name")}{_("title.Version")} - {_("title.Status")}{_("title.Description")}
, this.document, this.nodes); + DOM.fromJSON(["table", { highlight: "Addons", key: "list" }, + ["tr", { highlight: "AddonHead" }, + ["td", {}, _("title.Name")], + ["td", {}, _("title.Version")], + ["td"], + ["td", {}, _("title.Status")], + ["td", {}, _("title.Description")]]], + this.document, this.nodes); if (this._addons) this._init(); diff --git a/common/modules/dom.jsm b/common/modules/dom.jsm index 55a09996..0dd3f059 100644 --- a/common/modules/dom.jsm +++ b/common/modules/dom.jsm @@ -133,7 +133,7 @@ var DOM = Class("DOM", { if (val instanceof Ci.nsIDOMNode) return val; - if (typeof val == "xml") { + if (typeof val == "xml" || DOM.isJSONXML(val)) { val = dom.constructor(val, dom.document); if (container) container[idx] = val[0]; @@ -1562,15 +1562,14 @@ var DOM = Class("DOM", { let [name, attr] = args; attr = attr || {}; - if (Array.isArray(name) || args.length == 0) { + if (Array.isArray(name) || args.length == 0 || name == "") { var frag = doc.createDocumentFragment(); Array.forEach(args, function (arg) { - if (!Array.isArray(arg[0])) + if (!isArray(arg[0])) + arg = [arg]; + arg.forEach(function (arg) { frag.appendChild(tag(arg, namespaces)); - else - arg.forEach(function (arg) { - frag.appendChild(tag(arg, namespaces)); - }); + }); }); return frag; }