W3C home > Mailing lists > Public > public-webapi@w3.org > March 2008

Re: [Bindings] What does typeof return for interface objects?

From: Maciej Stachowiak <mjs@apple.com>
Date: Wed, 19 Mar 2008 00:08:05 -0700
Cc: "Web APIs WG (public)" <public-webapi@w3.org>
Message-Id: <F39AC2E0-1552-4CBD-9CEB-3FD6766E033B@apple.com>
To: Cameron McCormack <cam@mcc.id.au>

On Mar 18, 2008, at 11:06 PM, Cameron McCormack wrote:

> Travis Leithead:
>> I can think of some interesting use cases for implementing [[call]]
>> on an interface object... I'd prefer to leave it unspecified at best.
> OK.
>> I agree with Hixie on the point of specifying the behavior of typeof,
>> and to me typeof HTMLDocument == 'function' makes sense, since I  
>> think
>> of these as 'constructor objects' (even if they don't allow object
>> construction in some cases).
> But if you want ‘typeof HTMLDocument == 'function'’, then you would
> need to mandate [[Call]] being implemented on the interface object,
> since ECMA-262 says that the typeof operator returns 'function' only  
> if
> the object implements [[Call]].  And then if you require [[Call]] to  
> be
> implemented, then you’d need to say what that function would do.

ECMA-262 actually allows typeof to return anything at all for host  
objects (which all of the DOM binding objects are). So it would not be  
an ECMA-262 violation, technically, for an uncallable object to give  
typeof == 'function', but I do think it would be a bad idea.

In WebKit we currently follow the ECMA-262 callability-based approach  
even for host objects, but not all web engines do. For example, I  
believe that in Trident, NodeLists are callable but give a typeof  
result of 'object' instead of 'function'.

Received on Wednesday, 19 March 2008 07:08:44 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:16:25 UTC