May the defineProperty method of a proxy handler throw a TypeError?

David Flanagan dflanagan at mozilla.com
Thu May 26 10:10:56 PDT 2011


On 5/26/11 9:35 AM, David Flanagan wrote:
> On 5/26/11 6:36 AM, Tom Van Cutsem wrote:
>> Hi David,
>>
>> The short answer: if you also define a 'set' trap, throwing a 
>> TypeError from defineProperty() to signal rejection is appropriate
>
> Thanks.  I was worried that defineProperty() was required to honor 
> property changes since getOwnPropertyDescriptor() is required to say 
> that the properties are configurable.  (I've read the justification 
> for that in the proposal multiple times, but I've never been able to 
> understand it...)

Responding to my own message...  I think I now understand the 
configurable property requirement of getOwnPropertyDescriptor.  Is it 
for conformance with these paragraphs from §8.6.2 of the ECMA-262 spec?

> The [[GetOwnProperty]] internal method of a host object must conform 
> to the following invariants for each property of the host object:
> .    If a property is described as a data property and it may return 
> different values over time, then either or both of the [[Writable]] 
> and [[Configurable] attributes must be true even if no mechanism to 
> change the value is exposed via the other internal methods.
> .    If a property is described as a data property and its 
> [[Writable]] and [[Configurable]] are both false, then the SameValue 
> (according to 9.12) must be returned for the [[Value]] attribute of 
> the property on all calls to [[GetOwnProperty]].

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


More information about the es-discuss mailing list