samshull / node-proxy

Deprecated: Harmony Proxies in node (no longer needed)
MIT License
162 stars 29 forks source link

problem with creating handlers #3

Closed jifeon closed 13 years ago

jifeon commented 13 years ago

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 ).

samshull commented 13 years ago

What is the error message?

jifeon commented 13 years ago

___ 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

samshull commented 13 years ago

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.

samshull commented 13 years ago

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

jifeon commented 13 years ago

Works great!

Thank you.