Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TooTallNate/1165960 to your computer and use it in GitHub Desktop.
Save TooTallNate/1165960 to your computer and use it in GitHub Desktop.
From 47554e9443ba8882cfdb0008a1bb93a57d491270 Mon Sep 17 00:00:00 2001
From: Nathan Rajlich <nathan@tootallnate.net>
Date: Tue, 23 Aug 2011 10:39:23 -0700
Subject: [PATCH] Use Object.getPrototypeOf() on the object in the REPL tab-completion.
Some people use __proto__ to augment an Object's prototype after it's been created.
This patch helps make the "new" prototype properties visible if necessary.
This is also more consistent with the while logic below.
---
lib/repl.js | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/repl.js b/lib/repl.js
index 68fc116..252d52d 100644
--- a/lib/repl.js
+++ b/lib/repl.js
@@ -412,8 +412,8 @@ REPLServer.prototype.complete = function(line) {
memberGroups.push(Object.getOwnPropertyNames(obj));
}
// works for non-objects
- var p = obj.constructor ? obj.constructor.prototype : null;
try {
+ var p = Object.getPrototypeOf(obj);
var sentinel = 5;
while (p !== null) {
memberGroups.push(Object.getOwnPropertyNames(p));
--
1.7.3.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment