diff --git a/common/content/autocommands.js b/common/content/autocommands.js index 3246efcd..948a5e28 100644 --- a/common/content/autocommands.js +++ b/common/content/autocommands.js @@ -111,7 +111,7 @@ var AutoCommands = Module("autocommands", { ["tr", {}, ["td", { colspan: "3" }, ["span", { highlight: "Title" }, hive.name], - " ", /* E4X-FIXME: Filter is formatted E4X. */ String(hive.filter)]], + " ", hive.filter.toJSONXML(modules)]], ["tr", { style: "height: .5ex;" }], iter(cmds(hive)).map(function ([event, items]) [ ["tr", { style: "height: .5ex;" }], @@ -119,8 +119,7 @@ var AutoCommands = Module("autocommands", { ["tr", {}, ["td", { highlight: "Title", style: "padding-left: 1em; padding-right: 1em;" }, i == 0 ? event : ""], - // E4X-FIXME: ["td", {}, item.filter.toXML ? item.filter.toXML() : String(item.filter)], - ["td", {}, String(item.filter)], + ["td", {}, item.filter.toJSONXML ? item.filter.toJSONXML(modules) : String(item.filter)], ["td", {}, String(item.command)]]), ["tr", { style: "height: .5ex;" }]]).toArray(), ["tr", { style: "height: .5ex;" }], diff --git a/common/content/dactyl.js b/common/content/dactyl.js index 5130f915..3f0f0435 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -1294,7 +1294,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { b.name)), function ({ name, description }) [["dt", {}, name], - ["dd", {}, template.linkifyHelp(description, true)]], + ["dd", {}, template_.linkifyHelp(description, true)]], "\n")]]); }); }, diff --git a/common/modules/contexts.jsm b/common/modules/contexts.jsm index a9d4fd1d..e6a014fc 100644 --- a/common/modules/contexts.jsm +++ b/common/modules/contexts.jsm @@ -13,7 +13,7 @@ lazyRequire("commands", ["ArgType", "CommandOption", "commands"]); lazyRequire("options", ["Option"]); lazyRequire("overlay", ["overlay"]); lazyRequire("storage", ["File"]); -lazyRequire("template", ["template"]); +lazyRequire("template", ["template", "template_"]); var Const = function Const(val) Class.Property({ enumerable: true, value: val }); @@ -78,10 +78,11 @@ var Group = Class("Group", { return update(siteFilter, { toString: function () this.filters.join(","), - toXML: function (modules) let (uri = modules && modules.buffer.uri) - template.map(this.filters, - function (f) {f}, - <>,), + toJSONXML: function (modules) let (uri = modules && modules.buffer.uri) + template_.map(this.filters, + function (f) ["span", { highlight: uri && f(uri) ? "Filter" : "" }, + "toJSONXML" in f ? f.toJSONXML() : String(f)], + ","), filters: Option.parse.sitelist(patterns) }); @@ -668,12 +669,12 @@ var Contexts = Module("contexts", { { names: ["-description", "-desc", "-d"], description: "A description of this group", - default: ["User-defined group"], + default: "User-defined group", type: CommandOption.STRING }, { names: ["-locations", "-locs", "-loc", "-l"], - description: ["The URLs for which this group should be active"], + description: "The URLs for which this group should be active", default: ["*"], type: CommandOption.LIST }, @@ -799,7 +800,7 @@ var Contexts = Module("contexts", { context.keys = { active: function (group) group.filter(uri), text: "name", - description: function (g) <>{g.filter.toXML ? g.filter.toXML(modules) + <>  : ""}{g.description || ""} + description: function (g) ["", g.filter.toJSONXML ? g.filter.toJSONXML(modules).concat("\u00a0") : "", g.description || ""] }; context.completions = (active === undefined ? contexts.groupList : contexts.initializedGroups(active)) .slice(0, -1); diff --git a/common/modules/dom.jsm b/common/modules/dom.jsm index d23932c9..1c16d10d 100644 --- a/common/modules/dom.jsm +++ b/common/modules/dom.jsm @@ -1570,6 +1570,8 @@ var DOM = Class("DOM", { return args.toDOM(doc, namespaces, nodes); if (args instanceof Ci.nsIDOMNode) return args; + if ("toJSONXML" in args) + args = args.toJSONXML(); let [name, attr] = args; @@ -1606,8 +1608,13 @@ var DOM = Class("DOM", { var args = Array.slice(args, 2); var vals = parseNamespace(name); - var elem = doc.createElementNS(vals[0] || namespaces[""], - name); + try { + var elem = doc.createElementNS(vals[0] || namespaces[""], + name); + } + catch (e) { + util.dump("FOO", vals[0] || namespaces[""], name); + } for (var key in attr) if (!/^xmlns(?:$|:)/.test(key)) { @@ -1688,7 +1695,7 @@ var DOM = Class("DOM", { if (args == "") return ""; - if (isinstance(args, ["String", "Number", _, DOM.DOMString])) + if (isinstance(args, ["String", "Number", "Boolean", _, DOM.DOMString])) return indent + DOM.escapeHTML(String(args), true); @@ -1709,6 +1716,15 @@ var DOM = Class("DOM", { .serializeToString(args) .replace(/^/m, indent); + if ("toJSONXML" in args) + args = args.toJSONXML(); + + // Deal with common error case + if (args == null) { + util.reportError(Error("Unexpected null when processing XML.")); + return "[NULL]"; + } + let [name, attr] = args; if (isFragment(args)) {