Type of property names, as seen by proxy traps

David Bruant david.bruant at labri.fr
Thu Jul 7 05:24:32 PDT 2011

Le 07/07/2011 13:11, Tom Van Cutsem a écrit :
> 2011/7/6 Andreas Rossberg <rossberg at google.com 
> <mailto:rossberg at google.com>>
>     While putting together some test cases for Object.keys, I wondered: is
>     it intended that property names are always passed to traps as strings?
> That is indeed the intent.
>     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.
The return value of the trap is. The return value of 
this.getOwnPropertyNames isn't.
With a "pure" mapping from internal methods to trap, the trap call and 
handler.trap (this.trap) are the same. However, with invariant 
enforcement, they are different. Type coercion is a such an invariant 
enforcement (that actually could be added to FixedHandler).


> Cheers,
> Tom
>     /Andreas
>     _______________________________________________
>     es-discuss mailing list
>     es-discuss at mozilla.org <mailto:es-discuss at mozilla.org>
>     https://mail.mozilla.org/listinfo/es-discuss
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110707/45e46df5/attachment.html>

More information about the es-discuss mailing list