mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-23 19:45:46 +01:00
Poke iterator stuff more.
This commit is contained in:
@@ -121,8 +121,6 @@ var StatusLine = Module("statusline", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
cleanup: function cleanup(reason) {
|
cleanup: function cleanup(reason) {
|
||||||
util.dump("CLEANUP " + reason);
|
|
||||||
util.dump(this.statusBar.id, document.getElementById(this.statusBar.id));
|
|
||||||
if (reason != "unload" && "CustomizableUI" in window)
|
if (reason != "unload" && "CustomizableUI" in window)
|
||||||
CustomizableUI.unregisterArea(this.statusBar.id, false);
|
CustomizableUI.unregisterArea(this.statusBar.id, false);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1405,6 +1405,7 @@ function octal(decimal) parseInt(decimal, 8);
|
|||||||
* @param {nsIJSIID} iface The interface to which to query all elements.
|
* @param {nsIJSIID} iface The interface to which to query all elements.
|
||||||
* @returns {Generator}
|
* @returns {Generator}
|
||||||
*/
|
*/
|
||||||
|
let _iterator = "@@iterator" in [] ? "@@iterator" : "iterator";
|
||||||
function iter(obj, iface) {
|
function iter(obj, iface) {
|
||||||
if (arguments.length == 2 && iface instanceof Ci.nsIJSIID)
|
if (arguments.length == 2 && iface instanceof Ci.nsIJSIID)
|
||||||
return iter(obj).map(item => item.QueryInterface(iface));
|
return iter(obj).map(item => item.QueryInterface(iface));
|
||||||
@@ -1420,20 +1421,10 @@ function iter(obj, iface) {
|
|||||||
})();
|
})();
|
||||||
else if (isinstance(obj, ["Iterator", "Generator"]))
|
else if (isinstance(obj, ["Iterator", "Generator"]))
|
||||||
;
|
;
|
||||||
else if (isinstance(obj, ["Map Iterator"]))
|
else if (isinstance(obj, [Ci.nsIDOMHTMLCollection, Ci.nsIDOMNodeList]))
|
||||||
// This is stupid.
|
res = array.iterItems(obj);
|
||||||
res = (function () {
|
else if (_iterator in obj && callable(obj[_iterator]) && !("__iterator__" in obj))
|
||||||
for (;;) {
|
res = (x for (x of obj));
|
||||||
let { value, done } = obj.next();
|
|
||||||
if (done)
|
|
||||||
return;
|
|
||||||
|
|
||||||
yield value;
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
else if (isinstance(obj, ["Map"]))
|
|
||||||
// This is stupid.
|
|
||||||
res = (r for (r of obj));
|
|
||||||
else if (ctypes && ctypes.CData && obj instanceof ctypes.CData) {
|
else if (ctypes && ctypes.CData && obj instanceof ctypes.CData) {
|
||||||
while (obj.constructor instanceof ctypes.PointerType)
|
while (obj.constructor instanceof ctypes.PointerType)
|
||||||
obj = obj.contents;
|
obj = obj.contents;
|
||||||
@@ -1447,8 +1438,6 @@ function iter(obj, iface) {
|
|||||||
else
|
else
|
||||||
return iter({});
|
return iter({});
|
||||||
}
|
}
|
||||||
else if (isinstance(obj, [Ci.nsIDOMHTMLCollection, Ci.nsIDOMNodeList]))
|
|
||||||
res = array.iterItems(obj);
|
|
||||||
else if (Ci.nsIDOMNamedNodeMap && obj instanceof Ci.nsIDOMNamedNodeMap ||
|
else if (Ci.nsIDOMNamedNodeMap && obj instanceof Ci.nsIDOMNamedNodeMap ||
|
||||||
Ci.nsIDOMMozNamedAttrMap && obj instanceof Ci.nsIDOMMozNamedAttrMap)
|
Ci.nsIDOMMozNamedAttrMap && obj instanceof Ci.nsIDOMMozNamedAttrMap)
|
||||||
res = (function () {
|
res = (function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user