samshull/node-proxy

problem with creating handlers

jifeon opened this issue · 5 comments

I use that script ( http://code.google.com/p/es-lab/source/browse/trunk/src/proxies/forwardingHandler.js ) to handle an objects.

The code below works perfectly in fx4, but throws an error in node.

var some_obj = { prop : 42 };
var proxy = Proxy.create( new ForwardingHandler( some_obj ) );
console.log( proxy.prop );

Maybe it happens because link to source object is located in handler ( this.target in script ).

What is the error message?


___ jifeon at proxy say: node forwarding_handler.js

node.js:116
throw e; // process.nextTick error, or 'error' event on first tick
^
undefined

forwarding_handler.js is here: http://treeit.ru/forwarding_handler.js

node version: 0.4.2
os: fedora 14

This difference is actually caused by the fact that what node-proxy does is basically a hasOwnProperty check to ensure that the ProxyHandler has the minimum methods needed, but hasOwnProperty (or Has in V8) doesn't look back at the prototype chain. I will look into what methods are available for inspecting the prototype chain in V8.

Try the latest commit, the desired behavior should be functioning correctly now.

Works great!

Thank you.