On May 5, 2014, at 10:40 AM, John Barton wrote:

> I'm hoping someone can explain this result which surprises me.
> 
> If I create an object with a Proxy-ed prototype, the resulting object does 
> not obey .__proto__ equal Object.getPrototypeOf().
> 
> For example:
>   var aPrototype = {foo: 'foo'};
>   var handler = {
>     get: function(target, name, receiver) {
>       console.log('   (Proxy handler \'get\' called for name = ' + name + 
> ')');
>       return target[name];

the above line needs to be:
                 return Reflect.get(target, name, receiver);

Object.prototype.__proto__ is an accessor property and to work correctly it 
needs to have the originally accessed object passed at the this value.  That's 
why 'get' handlers (and others) have a 'receiver' argument.




>     }
>   };
>   var aProxy = Proxy(aPrototype, handler);
>   var hasProxyAsProto = Object.create(aProxy);
> 
> At this point, I expected 
>   hasProxyAsProto.__proto__ === aProxy
> but it it not true.  Moreover, the operation 
>   hasProxyAsProto.__proto__
> calls the Proxy handler get function with name === '__proto__': that makes no 
> sense as hasProxyAsProto is not a Proxy.
> 
> I tried this on Firefox 29 and Chrome 36.  Complete example is here: 
> https://gist.github.com/johnjbarton/f8a837104f0292fa088c

I can't speak to the correctness of those implementations but you need to have 
change for it to even have a chance of working.

Allen

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to