mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-07 23:54:12 +01:00
Death to for each.
This commit is contained in:
@@ -1212,7 +1212,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
get windows() [w for (w of overlay.windows)]
|
||||
|
||||
}, {
|
||||
toolbarHidden: function hidden(elem) (elem.getAttribute("autohide") || elem.getAttribute("collapsed")) == "true"
|
||||
toolbarHidden: function toolbarHidden(elem) "true" == (elem.getAttribute("autohide") ||
|
||||
elem.getAttribute("collapsed"))
|
||||
}, {
|
||||
cache: function initCache() {
|
||||
cache.register("help/plugins.xml", function () {
|
||||
@@ -1223,19 +1224,23 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
try {
|
||||
let info = contexts.getDocs(context);
|
||||
if (DOM.isJSONXML(info)) {
|
||||
let langs = info.slice(2).filter(e => isArray(e) && isObject(e[1]) && e[1].lang);
|
||||
let langs = info.slice(2)
|
||||
.filter(e => isArray(e) && isObject(e[1]) && e[1].lang);
|
||||
if (langs) {
|
||||
let lang = config.bestLocale(l[1].lang for each (l in langs));
|
||||
let lang = config.bestLocale(langs.map(l => l[1].lang));
|
||||
|
||||
info = info.slice(0, 2).concat(
|
||||
info.slice(2).filter(e => !isArray(e)
|
||||
|| !isObject(e[1])
|
||||
|| e[1].lang == lang));
|
||||
|
||||
for each (let elem in info.slice(2).filter(e => isArray(e) && e[0] == "info" && isObject(e[1])))
|
||||
for (let attr in values(["name", "summary", "href"]))
|
||||
info.slice(2)
|
||||
.filter(e => isArray(e) && e[0] == "info" && isObject(e[1]))
|
||||
.forEach(elem => {
|
||||
for (let attr of ["name", "summary", "href"])
|
||||
if (attr in elem[1])
|
||||
info[attr] = elem[1][attr];
|
||||
});
|
||||
}
|
||||
body.push(["h2", { xmlns: "dactyl", tag: info[1].name + '-plugin' },
|
||||
String(info[1].summary)]);
|
||||
|
||||
@@ -37,7 +37,7 @@ function require(module_, target) {
|
||||
}
|
||||
|
||||
function lazyRequire(module, names, target) {
|
||||
for each (let name in names)
|
||||
for (let name of names)
|
||||
memoize(target || this, name, name => require(module)[name]);
|
||||
}
|
||||
|
||||
@@ -284,9 +284,7 @@ function properties(obj, prototypes) {
|
||||
}
|
||||
|
||||
for (; obj; obj = prototypes && prototype(obj)) {
|
||||
var iter = (v for each (v in props(obj)));
|
||||
|
||||
for (let key in iter)
|
||||
for (let key of props(obj))
|
||||
if (!prototypes || !seen.add(key) && obj != orig)
|
||||
yield key;
|
||||
}
|
||||
@@ -670,7 +668,7 @@ function call(fn, self, ...args) {
|
||||
function memoize(obj, key, getter) {
|
||||
if (arguments.length == 1) {
|
||||
let res = update(Object.create(obj), obj);
|
||||
for each (let prop in Object.getOwnPropertyNames(obj)) {
|
||||
for (let prop of Object.getOwnPropertyNames(obj)) {
|
||||
let get = __lookupGetter__.call(obj, prop);
|
||||
if (get)
|
||||
memoize(res, prop, get);
|
||||
|
||||
@@ -10,7 +10,7 @@ function create(proto) Object.create(proto);
|
||||
|
||||
this["import"] = function import_(obj) {
|
||||
let res = {};
|
||||
for each (let key in Object.getOwnPropertyNames(obj))
|
||||
for (let key of Object.getOwnPropertyNames(obj))
|
||||
Object.defineProperty(res, key, Object.getOwnPropertyDescriptor(obj, key));
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -680,7 +680,7 @@ var Buffer = Module("Buffer", {
|
||||
return newURI.spec;
|
||||
}
|
||||
|
||||
for each (let shortener in Buffer.uriShorteners)
|
||||
for (let shortener of Buffer.uriShorteners)
|
||||
try {
|
||||
let shortened = shortener(uri, doc);
|
||||
if (shortened)
|
||||
|
||||
@@ -200,7 +200,7 @@ var Cache = Module("Cache", XPCOM(Ci.nsIRequestObserver), {
|
||||
}
|
||||
|
||||
if (this.localProviders.has(name) && !this.isLocal) {
|
||||
for each (let { cache } in overlay.modules)
|
||||
for (let { cache } of overlay.modules)
|
||||
if (cache._has(name))
|
||||
return cache.force(name, true);
|
||||
}
|
||||
@@ -267,7 +267,7 @@ var Cache = Module("Cache", XPCOM(Ci.nsIRequestObserver), {
|
||||
if (this.queue.length && !this.inQueue) {
|
||||
// removeEntry does not work properly with queues.
|
||||
let removed = 0;
|
||||
for each (let [, entry] in this.queue)
|
||||
for (let [, entry] of this.queue)
|
||||
if (this.getCacheWriter().hasEntry(entry)) {
|
||||
this.getCacheWriter().removeEntry(entry, false);
|
||||
removed++;
|
||||
|
||||
@@ -501,22 +501,21 @@ var CommandHive = Class("CommandHive", Contexts.Hive, {
|
||||
*/
|
||||
|
||||
cache: function cache() {
|
||||
let self = this;
|
||||
let { cache } = this.modules;
|
||||
this.cached = true;
|
||||
|
||||
let cached = cache.get(this.cacheKey, function () {
|
||||
self.cached = false;
|
||||
let cached = cache.get(this.cacheKey, () => {
|
||||
this.cached = false;
|
||||
this.modules.moduleManager.initDependencies("commands");
|
||||
|
||||
let map = {};
|
||||
for (let [name, cmd] in Iterator(self._map))
|
||||
for (let [name, cmd] in Iterator(this._map))
|
||||
if (cmd.sourceModule)
|
||||
map[name] = { sourceModule: cmd.sourceModule, isPlaceholder: true };
|
||||
|
||||
let specs = [];
|
||||
for (let cmd in values(self._list))
|
||||
for each (let spec in cmd.parsedSpecs)
|
||||
for (let cmd of this._list)
|
||||
for (let spec of cmd.parsedSpecs)
|
||||
specs.push(spec.concat(cmd.name));
|
||||
|
||||
return { map: map, specs: specs };
|
||||
|
||||
@@ -843,7 +843,7 @@ var CompletionContext = Class("CompletionContext", {
|
||||
}
|
||||
this.waitingForTab = false;
|
||||
this.runCount++;
|
||||
for each (let context in this.contextList)
|
||||
for (let context of this.contextList)
|
||||
context.lastActivated = this.runCount;
|
||||
this.contextList = [];
|
||||
},
|
||||
|
||||
@@ -85,7 +85,7 @@ var ConfigBase = Class("ConfigBase", {
|
||||
|
||||
loadConfig: function loadConfig(documentURL) {
|
||||
|
||||
for each (let config in this.configs) {
|
||||
for (let config of this.configs) {
|
||||
if (documentURL)
|
||||
config = config.overlays && config.overlays[documentURL] || {};
|
||||
|
||||
@@ -253,7 +253,7 @@ var ConfigBase = Class("ConfigBase", {
|
||||
// Horrible hack.
|
||||
let res = {};
|
||||
function process(manifest) {
|
||||
for each (let line in manifest.split(/\n+/)) {
|
||||
for (let line of manifest.split(/\n+/)) {
|
||||
let match = /^\s*(content|skin|locale|resource)\s+([^\s#]+)\s/.exec(line);
|
||||
if (match)
|
||||
res[match[2]] = true;
|
||||
@@ -271,7 +271,7 @@ var ConfigBase = Class("ConfigBase", {
|
||||
}
|
||||
}
|
||||
|
||||
for each (let dir in ["UChrm", "AChrom"]) {
|
||||
for (let dir of ["UChrm", "AChrom"]) {
|
||||
dir = File(services.directory.get(dir, Ci.nsIFile));
|
||||
if (dir.exists() && dir.isDirectory())
|
||||
for (let file in dir.iterDirectory())
|
||||
@@ -398,7 +398,7 @@ var ConfigBase = Class("ConfigBase", {
|
||||
dtd: Class.Memoize(function ()
|
||||
iter(this.dtdExtra,
|
||||
(["dactyl." + k, v] for ([k, v] in iter(config.dtdDactyl))),
|
||||
(["dactyl." + s, config[s]] for each (s in config.dtdStrings)))
|
||||
(["dactyl." + s, config[s]] for (s of config.dtdStrings)))
|
||||
.toObject()),
|
||||
|
||||
dtdDactyl: memoize({
|
||||
@@ -455,7 +455,7 @@ var ConfigBase = Class("ConfigBase", {
|
||||
["menupopup", { id: "viewSidebarMenu", xmlns: "xul" }],
|
||||
["broadcasterset", { id: "mainBroadcasterSet", xmlns: "xul" }]];
|
||||
|
||||
for each (let [id, [name, key, uri]] in Iterator(this.sidebars)) {
|
||||
for (let [id, [name, key, uri]] in Iterator(this.sidebars)) {
|
||||
append[0].push(
|
||||
["menuitem", { observes: "pentadactyl-" + id + "Sidebar", label: name,
|
||||
accesskey: key }]);
|
||||
|
||||
@@ -94,7 +94,7 @@ var Contexts = Module("contexts", {
|
||||
},
|
||||
|
||||
cleanup: function () {
|
||||
for each (let module in this.pluginModules)
|
||||
for (let module of this.pluginModules)
|
||||
util.trapErrors("unload", module);
|
||||
|
||||
this.pluginModules = {};
|
||||
@@ -144,12 +144,12 @@ var Contexts = Module("contexts", {
|
||||
},
|
||||
|
||||
cleanup: function () {
|
||||
for each (let hive in this.groupList.slice())
|
||||
for (let hive of this.groupList.slice())
|
||||
util.trapErrors("cleanup", hive, "shutdown");
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
for each (let hive in values(this.groupList.slice()))
|
||||
for (let hive of values(this.groupList.slice()))
|
||||
util.trapErrors("destroy", hive, "shutdown");
|
||||
|
||||
for each (let plugin in this.modules.plugins.contexts) {
|
||||
@@ -340,7 +340,7 @@ var Contexts = Module("contexts", {
|
||||
delete contexts.pluginModules[canonical];
|
||||
}
|
||||
|
||||
for each (let { plugins } in overlay.modules)
|
||||
for (let { plugins } of overlay.modules)
|
||||
if (plugins[this.NAME] == this)
|
||||
delete plugins[this.name];
|
||||
})
|
||||
|
||||
@@ -474,7 +474,7 @@ var DOM = Class("DOM", {
|
||||
|
||||
let charset = doc.characterSet;
|
||||
let converter = services.CharsetConv(charset);
|
||||
for each (let cs in form.acceptCharset.split(/\s*,\s*|\s+/)) {
|
||||
for (let cs of form.acceptCharset.split(/\s*,\s*|\s+/)) {
|
||||
let c = services.CharsetConv(cs);
|
||||
if (c) {
|
||||
converter = services.CharsetConv(cs);
|
||||
|
||||
@@ -204,11 +204,11 @@ var Highlights = Module("Highlight", {
|
||||
node.setAttributeNS(NS, "highlight", group);
|
||||
|
||||
let groups = group.split(" ");
|
||||
for each (let group in groups)
|
||||
for (let group of groups)
|
||||
this.loaded[group] = true;
|
||||
|
||||
if (applyBindings)
|
||||
for each (let group in groups) {
|
||||
for (let group of groups) {
|
||||
if (applyBindings.bindings && group in applyBindings.bindings)
|
||||
applyBindings.bindings[group](node, applyBindings);
|
||||
else if (group in template.bindings)
|
||||
|
||||
@@ -237,7 +237,7 @@ overlay.overlayWindow(Object.keys(config.overlays),
|
||||
},
|
||||
|
||||
unload: function unload(window) {
|
||||
for each (let mod in this.modules.moduleList.reverse()) {
|
||||
for (let mod of this.modules.moduleList.reverse()) {
|
||||
mod.stale = true;
|
||||
|
||||
if ("destroy" in mod)
|
||||
|
||||
@@ -218,7 +218,7 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
|
||||
_loadOverlays: function _loadOverlays(window) {
|
||||
let overlays = this.getData(window, "overlays");
|
||||
|
||||
for each (let obj in overlay.overlays[window.document.documentURI] || []) {
|
||||
for (let obj of overlay.overlays[window.document.documentURI] || []) {
|
||||
if (~overlays.indexOf(obj))
|
||||
continue;
|
||||
overlays.push(obj);
|
||||
@@ -391,7 +391,7 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
|
||||
}, this);
|
||||
|
||||
return function unwrap() {
|
||||
for each (let k in Object.getOwnPropertyNames(original))
|
||||
for (let k of Object.getOwnPropertyNames(original))
|
||||
if (Object.getOwnPropertyDescriptor(object, k).configurable)
|
||||
Object.defineProperty(object, k, Object.getOwnPropertyDescriptor(original, k));
|
||||
else {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com>
|
||||
// Copyright (c) 2008-2014 Kris Maglione <maglione.k@gmail.com>
|
||||
//
|
||||
// This work is licensed for reuse under an MIT license. Details are
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
@@ -143,8 +143,8 @@ ProtocolBase.prototype = {
|
||||
};
|
||||
|
||||
function LocaleChannel(pkg, locale, path, orig) {
|
||||
for each (let locale in [locale, "en-US"])
|
||||
for each (let sep in "-/") {
|
||||
for (let locale of [locale, "en-US"])
|
||||
for (let sep of "-/") {
|
||||
var channel = Channel(["resource:/", pkg + sep + locale, path].join("/"), orig, true, true);
|
||||
if (channel)
|
||||
return channel;
|
||||
|
||||
@@ -155,7 +155,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
|
||||
}
|
||||
|
||||
// "Never remember passwords" ...
|
||||
for each (let domain in services.loginManager.getAllDisabledHosts())
|
||||
for (let domain of services.loginManager.getAllDisabledHosts())
|
||||
if (!host || util.isSubdomain(domain, host))
|
||||
services.loginManager.setLoginSavingEnabled(host, true);
|
||||
},
|
||||
|
||||
@@ -184,7 +184,7 @@ var Services = Module("Services", {
|
||||
function () callable(XPCOMShim(this.interfaces)[this.init]));
|
||||
|
||||
this[name] = (function Create() this._create(name, arguments)).bind(this);
|
||||
update.apply(null, [this[name]].concat([Ci[i] for each (i in Array.concat(ifaces))]));
|
||||
update.apply(null, [this[name]].concat([Ci[i] for (i of Array.concat(ifaces))]));
|
||||
return this[name];
|
||||
},
|
||||
|
||||
|
||||
@@ -452,7 +452,7 @@ var File = Class("File", {
|
||||
child: function child() {
|
||||
let f = this.constructor(this);
|
||||
for (let [, name] in Iterator(arguments))
|
||||
for each (let elem in name.split(File.pathSplit))
|
||||
for (let elem of name.split(File.pathSplit))
|
||||
f.append(elem);
|
||||
return f;
|
||||
},
|
||||
|
||||
@@ -269,7 +269,7 @@ var Styles = Module("Styles", {
|
||||
},
|
||||
|
||||
cleanup: function cleanup() {
|
||||
for each (let hive in this.hives)
|
||||
for (let hive of this.hives || [])
|
||||
util.trapErrors("cleanup", hive);
|
||||
this.hives = [];
|
||||
this.user = this.addHive("user", this, true);
|
||||
@@ -368,7 +368,7 @@ var Styles = Module("Styles", {
|
||||
}, {
|
||||
append: function (dest, src, sort) {
|
||||
let props = {};
|
||||
for each (let str in [dest, src])
|
||||
for (let str of [dest, src])
|
||||
for (let prop in Styles.propertyIter(str))
|
||||
props[prop.name] = prop.value;
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ var Template = Module("Template", {
|
||||
|
||||
let res = [];
|
||||
let n = 0;
|
||||
for each (let i in Iterator(iter)) {
|
||||
for (let i in Iterator(iter)) {
|
||||
let val = func(i, n);
|
||||
if (val == undefined)
|
||||
continue;
|
||||
|
||||
@@ -895,7 +895,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
let windows = services.windowMediator.getXULWindowEnumerator(null);
|
||||
while (windows.hasMoreElements()) {
|
||||
let window = windows.getNext().QueryInterface(Ci.nsIXULWindow);
|
||||
for each (let type in types) {
|
||||
for (let type of types) {
|
||||
let docShells = window.docShell.getDocShellEnumerator(Ci.nsIDocShellTreeItem[type],
|
||||
Ci.nsIDocShell.ENUMERATE_FORWARDS);
|
||||
while (docShells.hasMoreElements())
|
||||
|
||||
Reference in New Issue
Block a user