Skip to content

Commit

Permalink
__proto__ trick to make instanceof work on cloned objects
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Aug 19, 2010
1 parent 2a1f530 commit 130a833
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/traverse.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ function Traverse (refObj) {
Object.keys(ref).forEach(function (key) {
node[key] = clone(ref[key]);
});
// To make instanceof work:
if ('__proto__' in ref) node.__proto__ = ref.__proto__;
// Probably there are other attributes worth copying
return node;
}
else {
Expand Down

0 comments on commit 130a833

Please sign in to comment.