Just noticed that David Bruant already proposed Object.prototype.toPropertyDescriptor for this exact same reason in https://mail.mozilla.org/pipermail/es-discuss/2011-May/013971.html, apologies. I think it is better as a static (class) method since it is reflection-related, and to avoid attackers from defining a bogus "toPropertyDescriptor" method on property descriptors.
On Tue, Jul 5, 2011 at 12:55 PM, Sean Eagan <[email protected]> wrote: > On Tue, Jul 5, 2011 at 9:45 AM, Sean Eagan <[email protected]> wrote: >> I think if an "Object.toPropertyDescriptor" function were introduced, >> then this protection burden may be sufficiently small. This would be >> similar to the FixedHandler approach of providing *optional* builtin >> invariant maintenance support. The first argument to this function >> would be the object to convert to a property descriptor, and there >> could potentially be a second argument which could be a boolean as to >> whether to keep non-standard attributes. > > Object.toPropertyDescriptor could also allow us to directly return > "getOwnPropertyDescriptor" trap return values, as this value could > then be tamed by proxy consumers in a standard, efficient, and > convenient manner. > > Cheers, > Sean Eagan > -- Sean Eagan _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

