summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorKris Maglione <maglione.k@gmail.com>2014-02-17 20:04:45 -0800
committerKris Maglione <maglione.k@gmail.com>2014-02-17 20:04:45 -0800
commit1963b49ab01f7acd9053c6a1d2be81c3e1696011 (patch)
treeec0da0c33bd4380c69dfc86805f3c08f3d509fd1 /common
parent512b01d57468d990305b369a794ff0564806285f (diff)
downloadpentadactyl-1963b49ab01f7acd9053c6a1d2be81c3e1696011.tar.gz
Fix iteration over whacky Map Iterators.
Diffstat (limited to 'common')
-rw-r--r--common/content/dactyl.js2
-rw-r--r--common/modules/base.jsm16
2 files changed, 13 insertions, 5 deletions
diff --git a/common/content/dactyl.js b/common/content/dactyl.js
index f0061c17..9d4cbcfe 100644
--- a/common/content/dactyl.js
+++ b/common/content/dactyl.js
@@ -1634,7 +1634,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
if (args["+purgecaches"])
cache.flush();
- util.delay(function () { util.rehash(args) });
+ util.delay(() => { util.rehash(args) });
},
{
argCount: "0", // FIXME
diff --git a/common/modules/base.jsm b/common/modules/base.jsm
index 58e1744e..9f3ec1a0 100644
--- a/common/modules/base.jsm
+++ b/common/modules/base.jsm
@@ -1409,10 +1409,6 @@ function iter(obj, iface) {
if (arguments.length == 2 && iface instanceof Ci.nsIJSIID)
return iter(obj).map(item => item.QueryInterface(iface));
- if (isinstance(obj, ["Map Iterator"]))
- // This is stupid.
- obj = { __iterator__: (function () this).bind(obj) };
-
let args = arguments;
let res = Iterator(obj);
@@ -1424,6 +1420,17 @@ function iter(obj, iface) {
})();
else if (isinstance(obj, ["Iterator", "Generator"]))
;
+ else if (isinstance(obj, ["Map Iterator"]))
+ // This is stupid.
+ res = (function () {
+ for (;;) {
+ let { value, done } = obj.next();
+ if (done)
+ return;
+
+ yield value;
+ }
+ })();
else if (isinstance(obj, ["Map"]))
// This is stupid.
res = (r for (r of obj));
@@ -1603,6 +1610,7 @@ const Iter = Class("Iter", {
__iterator__: function () this.iter
});
+iter.Iter = Iter;
/**
* Array utility methods.