2013/9/11 David Bruant <bruan...@gmail.com> > Le 11/09/2013 06:10, Boris Zbarsky a écrit : > > Hey all, >> >> I was looking at implementing a membrane using ES6 proxies and ran into a >> snag. Consider a situation where object A has prototype B. A' is a proxy >> implementing the membrane, whose target is A. >> >> But now if Object.getPrototypeOf(A') is invoked the return value will be >> B (unless it just throws). There's no way for A' to return a new proxy B' >> whose target is B in this situation. >> > In essence yes. In practice, you can do: > // trap: > getPrototypeOf: function(target){ > target.__proto__ = B'; > return B'; > } > But of course, it changes A [[Prototype]], which is probably not > desirable. And of course, although to-be-standard, __proto__ is bad taste... >
Indeed, this is also the pattern I used, except it doesn't set the `__proto__` of the real target, but of a shadow target: < https://github.com/tvcutsem/harmony-reflect/blob/master/examples/membrane.js#L246 >. Setting `__proto__` may be bad taste in general, but this is a case where using this capability is necessary. Ps: btw, wasn't "GetInheritance" supposed to be renamed "GetPrototype"? > I think we had agreement on that. Allen? Cheers, Tom
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss