summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKris Maglione <maglione.k@gmail.com>2014-02-24 19:03:49 -0800
committerKris Maglione <maglione.k@gmail.com>2014-02-24 19:03:49 -0800
commit5b38465a1c0437af9e01e7e3fa2790a1cef2268a (patch)
treee14a13ea8f908e03d9c31ead259442240ab331f8
parent78a6de9c3adac6906f0a469ddfe5f18bc9091880 (diff)
downloadpentadactyl-5b38465a1c0437af9e01e7e3fa2790a1cef2268a.tar.gz
Death to `for each`.
-rw-r--r--common/content/dactyl.js15
-rw-r--r--common/modules/base.jsm8
-rw-r--r--common/modules/bootstrap.jsm2
-rw-r--r--common/modules/buffer.jsm2
-rw-r--r--common/modules/cache.jsm4
-rw-r--r--common/modules/commands.jsm11
-rw-r--r--common/modules/completion.jsm2
-rw-r--r--common/modules/config.jsm10
-rw-r--r--common/modules/contexts.jsm8
-rw-r--r--common/modules/dom.jsm2
-rw-r--r--common/modules/highlight.jsm4
-rw-r--r--common/modules/main.jsm2
-rw-r--r--common/modules/overlay.jsm4
-rw-r--r--common/modules/protocol.jsm6
-rw-r--r--common/modules/sanitizer.jsm2
-rw-r--r--common/modules/services.jsm2
-rw-r--r--common/modules/storage.jsm2
-rw-r--r--common/modules/styles.jsm4
-rw-r--r--common/modules/template.jsm2
-rw-r--r--common/modules/util.jsm2
20 files changed, 48 insertions, 46 deletions
diff --git a/common/content/dactyl.js b/common/content/dactyl.js
index 2d932031..5429f215 100644
--- a/common/content/dactyl.js
+++ b/common/content/dactyl.js
@@ -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)]);
diff --git a/common/modules/base.jsm b/common/modules/base.jsm
index 82e99b61..3ca4ca70 100644
--- a/common/modules/base.jsm
+++ b/common/modules/base.jsm
@@ -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);
diff --git a/common/modules/bootstrap.jsm b/common/modules/bootstrap.jsm
index 9df81ca6..1325f294 100644
--- a/common/modules/bootstrap.jsm
+++ b/common/modules/bootstrap.jsm
@@ -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;
}
diff --git a/common/modules/buffer.jsm b/common/modules/buffer.jsm
index 7a9247a9..faafb47c 100644
--- a/common/modules/buffer.jsm
+++ b/common/modules/buffer.jsm
@@ -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)
diff --git a/common/modules/cache.jsm b/common/modules/cache.jsm
index 0f13ca1e..fc045954 100644
--- a/common/modules/cache.jsm
+++ b/common/modules/cache.jsm
@@ -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++;
diff --git a/common/modules/commands.jsm b/common/modules/commands.jsm
index ca03051c..e9bd2e07 100644
--- a/common/modules/commands.jsm
+++ b/common/modules/commands.jsm
@@ -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 };
diff --git a/common/modules/completion.jsm b/common/modules/completion.jsm
index b1aa205e..7d2b6c11 100644
--- a/common/modules/completion.jsm
+++ b/common/modules/completion.jsm
@@ -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 = [];
},
diff --git a/common/modules/config.jsm b/common/modules/config.jsm
index 5b252a62..47b6d323 100644
--- a/common/modules/config.jsm
+++ b/common/modules/config.jsm
@@ -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 }]);
diff --git a/common/modules/contexts.jsm b/common/modules/contexts.jsm
index 20a7e5b9..51fb0ec6 100644
--- a/common/modules/contexts.jsm
+++ b/common/modules/contexts.jsm
@@ -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];
})
diff --git a/common/modules/dom.jsm b/common/modules/dom.jsm
index 5061133f..e8fa7bc2 100644
--- a/common/modules/dom.jsm
+++ b/common/modules/dom.jsm
@@ -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);
diff --git a/common/modules/highlight.jsm b/common/modules/highlight.jsm
index ae02af9e..501edde2 100644
--- a/common/modules/highlight.jsm
+++ b/common/modules/highlight.jsm
@@ -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)
diff --git a/common/modules/main.jsm b/common/modules/main.jsm
index fb02a5fe..6043d5e4 100644
--- a/common/modules/main.jsm
+++ b/common/modules/main.jsm
@@ -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)
diff --git a/common/modules/overlay.jsm b/common/modules/overlay.jsm
index 9d96f184..9753061a 100644
--- a/common/modules/overlay.jsm
+++ b/common/modules/overlay.jsm
@@ -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 {
diff --git a/common/modules/protocol.jsm b/common/modules/protocol.jsm
index f73e2092..d5e6d1a3 100644
--- a/common/modules/protocol.jsm
+++ b/common/modules/protocol.jsm
@@ -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;
diff --git a/common/modules/sanitizer.jsm b/common/modules/sanitizer.jsm
index 1c59c4b6..be0629dc 100644
--- a/common/modules/sanitizer.jsm
+++ b/common/modules/sanitizer.jsm
@@ -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);
},
diff --git a/common/modules/services.jsm b/common/modules/services.jsm
index 0af641de..1b3def2d 100644
--- a/common/modules/services.jsm
+++ b/common/modules/services.jsm
@@ -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];
},
diff --git a/common/modules/storage.jsm b/common/modules/storage.jsm
index 96ce7ed6..359c0394 100644
--- a/common/modules/storage.jsm
+++ b/common/modules/storage.jsm
@@ -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;
},
diff --git a/common/modules/styles.jsm b/common/modules/styles.jsm
index 41a67a3b..d4ce815f 100644
--- a/common/modules/styles.jsm
+++ b/common/modules/styles.jsm
@@ -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;
diff --git a/common/modules/template.jsm b/common/modules/template.jsm
index 39ce2f97..e2e87292 100644
--- a/common/modules/template.jsm
+++ b/common/modules/template.jsm
@@ -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;
diff --git a/common/modules/util.jsm b/common/modules/util.jsm
index ca69b092..4c0aca36 100644
--- a/common/modules/util.jsm
+++ b/common/modules/util.jsm
@@ -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())