From 870538e032ffce15a1bfdc212d73782f6cbfa7d1 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Tue, 18 Nov 2008 02:01:40 +0000 Subject: [PATCH] Ameliorate completion with wrappedJSObjects a bit --- content/completion.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/content/completion.js b/content/completion.js index d41d0760..b69e83b4 100644 --- a/content/completion.js +++ b/content/completion.js @@ -150,20 +150,21 @@ function Completion() //{{{ // Things we can dereference if (["object", "string", "function"].indexOf(typeof obj) == -1) continue; - /* Try harder. - if (/^\[XPCNativeWrapper /.test(obj)) - obj = obj.wrappedJSObject; - */ - try - { - if (obj.wrappedJSObject) - obj = obj.wrappedJSObject; - } - catch (e) {} - for (let [k, v] in this.iter(obj)) - compl.push([k, v]); + // XPCNativeWrappers, etc, don't show all accessible + // members until they're accessed, so, we look at + // the wrappedJSObject instead, and return any keys + // available in the object itself. + let orig = obj; + if (obj.wrappedJSObject) + obj = obj.wrappedJSObject; + compl.push([v for (v in this.iter(obj)) if (v[0] in orig)]) + // And if wrappedJSObject happens to be available, + // return that, too. + if (orig.wrappedJSObject) + compl.push([["wrappedJSObject", obj]]); } + compl = util.Array.flatten(compl); return cacheResults.js = compl; }