not sure I understand but ...
> that makes no sense as hasProxyAsProto is not a Proxy
it's inheriting from a Proxy so where is the surprise? it does what I'd
expect it to do, pass through the inherited Proxy same as you pass through
inherited get/set methods when creating from an object that has get/set
behaviors
Moreover, since you inheriting a proxy that reacts on accessors you have
the right behavior when you access `__proto__`, the `target.__proto__`
should be returned instead.
Last, but not least, `__proto__` is an `Object.prototype` property that has
nothing to do with `Object.getPrototypeOf` .... you can redefine
`__proto__` behavior either in the `Object.prototype` itself, through a
proxy, or within an object, but that won't affect returned value of
`Object.getPrototypeOf`
```javascript
var o = {};
Object.defineProperty(o, '__proto__', {
get: function () {
return String.prototype;
}
});
o.__proto__ === String.prototype;
Object.getPrototypeOf(o); // Object.prototype
```
Best Regards
On Mon, May 5, 2014 at 10:40 AM, John Barton <[email protected]> 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];
> }
> };
> 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
>
> Any ideas?
> jjb
>
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss