Type of property names, as seen by proxy traps
david.bruant at labri.fr
Thu Jul 7 05:32:40 PDT 2011
Le 07/07/2011 14:29, Andreas Rossberg a écrit :
> On 7 July 2011 13:11, Tom Van Cutsem<tomvc.be at gmail.com> wrote:
>> 2011/7/6 Andreas Rossberg<rossberg at google.com>
>>> It seems like a reasonable assumption, but is not currently the case
>>> everywhere (e.g. the default implementation for `keys' can violate
>>> this assumption when passing names to this.getOwnPropertyDescriptor).
>> How so? The default implementation for the keys trap relies on the return
>> value of the getOwnPropertyNames() trap, whose return value is coerced to an
>> array of Strings.
> Not quite. The coercion is taking place in Object.getOwnPropertyNames,
> but the default `keys' trap doesn't go through that, but instead calls
> the trap directly. Moreover, it has to do it like that, because it
> doesn't even have a reference to the proxy itself.
However, if we assume that the getOwnPropertyNames trap is able to do
type coercion on its output, there is no reason for the keys trap to not
do that too, regardless of how it was implemented.
More information about the es-discuss