mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 16:32:27 +01:00
Override iterators for JS completion. This is evil, and hacky, and completely worth it.
This commit is contained in:
@@ -323,6 +323,23 @@ liberator.Completion = function () //{{{
|
|||||||
if (!(objects instanceof Array))
|
if (!(objects instanceof Array))
|
||||||
objects = [objects];
|
objects = [objects];
|
||||||
|
|
||||||
|
let iter = function (obj)
|
||||||
|
{
|
||||||
|
let iter = Iterator(obj);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ("__iterator__" in obj)
|
||||||
|
{
|
||||||
|
let oldIter = obj.__iterator__;
|
||||||
|
delete obj.__iterator__;
|
||||||
|
iter = Iterator(obj);
|
||||||
|
obj.__iterator__ = oldIter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {}
|
||||||
|
return iter;
|
||||||
|
}
|
||||||
|
|
||||||
let compl = [];
|
let compl = [];
|
||||||
for (let [,obj] in Iterator(objects))
|
for (let [,obj] in Iterator(objects))
|
||||||
{
|
{
|
||||||
@@ -331,18 +348,9 @@ liberator.Completion = function () //{{{
|
|||||||
if (typeof obj != "object")
|
if (typeof obj != "object")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (let k in obj)
|
for (let [k, v] in iter(obj))
|
||||||
{
|
{
|
||||||
let v, type;
|
let type = typeof v;
|
||||||
try
|
|
||||||
{
|
|
||||||
v = obj[k];
|
|
||||||
type = typeof v;
|
|
||||||
}
|
|
||||||
catch(e)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (["string", "number", "boolean"].indexOf(type) > -1)
|
if (["string", "number", "boolean"].indexOf(type) > -1)
|
||||||
type += ": " + String(v).replace("\n", "\\n", "g");
|
type += ": " + String(v).replace("\n", "\\n", "g");
|
||||||
if (type == "function")
|
if (type == "function")
|
||||||
|
|||||||
Reference in New Issue
Block a user