1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-03 04:35:46 +01:00

Death to E4X and stuff.

This commit is contained in:
Kris Maglione
2012-12-16 23:00:58 -08:00
parent d8515c1548
commit 6a87343724
4 changed files with 31 additions and 15 deletions

View File

@@ -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;" }],

View File

@@ -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")]]);
});
},

View File

@@ -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) <span highlight={uri && f(uri) ? "Filter" : ""}>{f}</span>,
<>,</>),
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) + <>&#xa0;</> : ""}{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);

View File

@@ -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)) {