[whatwg] HTML 5 : Misconceptions Documented

On Aug 7, 2008, at 1:51 PM, Garrett Smith wrote:

> On Wed, Aug 6, 2008 at 7:06 PM, Maciej Stachowiak <mjs at apple.com>  
> wrote:
>>
>> On Aug 6, 2008, at 7:17 AM, Thomas Broyer wrote:
>>
>>> On Wed, Aug 6, 2008 at 11:29 AM, Maciej Stachowiak wrote:
>>>>
>
>
>>>> I think Web IDL should provide a formalism to cater to this,  
>>>> because
>>>> nearly
>>>> all bindings with special dynamic properties work like this  
>>>> afaik. But I
>>>> think it would have to involve a pseudo-method for the  
>>>> "hasOwnProperty"
>>>> check (which "in" is based on).
>>>
>>> hasOwnProperty is ECMAScript-specific.
>>
>
> Yes it is.
>
>> The Web IDL includes specific requirements for how to map an  
>> interface
>> specified in Web IDL to ECMAScript. So, indeed, that would be the  
>> part of
>> the Web IDL spec that would be the best place to define this.
>>
>
> Since Maciej is probably considered to be an EcmaScript expert and I
> am not, and since he had stated that 'in' calls 'hasOwnProperty', and
> even continued to argue the claim, it is necessary and appropriate to
> demonstrate proof that the 'in' does not call 'hasOwnProperty'.
>
> The following example shows that no implementation calls
> hasOwnProperty with use of 'in' operator.

The more accurate way to put it would be that the 'in' operator  
performs the same check at ever item in the prototype chain (including  
the original object) that the original value of hasOwnProperty  
performs on only the object itself. You are correct that replacing  
hasOwnProperty either on an object or in its prototype chain will have  
no effect on operation of the 'in' operator.

> 'hasOwnProperty' is EcmaScript specific. Whether or not ordinally
> indexed properties should be 'own' properties is not a place for IDL
> to decide.

It is just as relevant to specify whether a property is an own  
property as it is to specify whether it is visible to the 'in'  
operator. Both are edge cases that may affect interoperability but  
likely won't (since most authors will just get the property, and not  
check for presence). Visibility to the 'in' operator seems to  
observable difference on which you base your distinction between  
'having a getter' and 'having a real property'.

Regards,
Maciej

Received on Thursday, 7 August 2008 14:16:56 UTC