Reflect.defineProperty + FromPropertyDescriptor & ToPropertyDescriptor

Allen Wirfs-Brock allen at
Tue Sep 4 16:02:39 UTC 2018

> On Sep 4, 2018, at 12:32 AM, Darien Valentine <valentinium at <mailto:valentinium at>> wrote:
> My understanding was that, in theory, using `Reflect` as your handler object should mean the behavior of all the trapped operations should be the same as it would have been for an ordinary object. This may be an incorrect assumption on my part (are there other examples like this?), but it does seem desirable for that to be true.

Yes, this is surprising (at least to me) and slightly disturbing.

At one point, early in the development of ES6 the draft spec. had a [[OriginalDescriptor]] field  (that may not be the actual name I used) in internal PropertyDescrptors that carried along a reference to the original descriptor object from which the PropertyDescriptor was derived. When the Proxy traps needed to reify a PropertyDescriptor as an object it would use the [[OriginalDescriptor]] if it had a value. The reason for having [[OriginalDescriptor]] wasn’t because of inheriting from %ObjectPrototype%.  It was to enable Proxies to extend property descriptor objects with additional attributes (for example, imagine a public: <boolean> attribute) that the Proxy handler could then interpret.

[[OriginalDescriptor]] was removed from the spec. after some implementors pushed back with cncerns about the added complexity and skepticism about the value of the added utility.

> I’m curious about whether changes to these algorithms to alter this behavior in some way would be web-safe. 

Unlikely, part of the original intent of the descriptor object design was that prototypal inheritance could be used compose descriptor objects (BTW, there are es-discuss threads about these inheritance issues far older than the one you referenced).  consider:

function friendlyDefaults (desc) {return Object.setPrototypeOf(desc, {enumerable: true, configurable: true, writable: true})};

var obj = Object.create(Object.prototype, {
   p1: friendlyDefaults({value: 1}),
   p2: friendlyDefaults({value: 2}),
   p3: friendlyDefaults({value: 3})

I won’t want to bet that nobody on the web has ever used prototypal inheritance to construct their property descriptors.

Similarly, I won’t want to bet that nobody on the web has written a Proxy trap handler where they have invoked the hasOwnProperty method on a reified descriptor object.

I think that bringing back the [[OriginalDescriptor]] concept might be web-safe, but good luck on convincing implementors that this problem is worth the effort. (I actually think, the overhead would not be so bad because implementations don’t actually  create PropertyDescriptors in normal operation.  It is only operations that start with a Object.* or Reflect.* operation that create the round tripping concern.)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list