Skip to content
Browse files

"Real" scope.

Related: bug 775806
(Some DOM properties are enumerable, but are not on the prototype chain.)
  • Loading branch information...
1 parent 84d9fca commit 93ef634cbc88d812c83ca85e169776546ae57578 @espadrine committed Jul 19, 2012
Showing with 14 additions and 7 deletions.
  1. +14 −7 webconsole-autocomplete.diff
View
21 webconsole-autocomplete.diff
@@ -24,26 +24,33 @@ diff --git a/browser/devtools/webconsole/WebConsoleUtils.jsm b/browser/devtools/
return null;
}
-@@ -929,8 +929,23 @@ function JSPropertyProvider(aScope, aInp
+@@ -929,8 +929,30 @@ function JSPropertyProvider(aScope, aInp
return null;
}
+ // Array of strings of all properties on this object.
+ function getScope(obj) {
+ let names = Object.getOwnPropertyNames(obj);
-+ let parent;
-+ if ((parent = Object.getPrototypeOf(obj)) !== null) {
-+ let superNames = getScope(parent);
-+ for (let i = 0; i < superNames; i++) {
-+ names.push(superNames[i]);
++ obj = Object.getPrototypeOf(obj);
++ if (obj !== null) {
++ names.concat(getScope(obj));
++ }
++ return names;
++ }
++
++ function getRealScope(obj) {
++ let names = getScope(obj);
++ for (var prop in obj) {
++ if (names.indexOf(prop) === -1) {
++ names.push(prop);
+ }
+ }
+ return names;
+ }
+
let matches = [];
- for (let prop in obj) {
-+ let names = getScope(obj);
++ let names = getRealScope(obj);
+ for (let i = 0; i < names.length; i++) {
+ let prop = names[i];
if (prop.indexOf(matchProp) == 0) {

0 comments on commit 93ef634

Please sign in to comment.
Something went wrong with that request. Please try again.