On Mar 19, 2008, at 12:08 AM, Maciej Stachowiak wrote:


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'.

Alexey points out that we have had a bug filed because we report 'function' in this case: <http://bugs.webkit.org/show_bug.cgi?id=14547>.

But it's not really clear if the IE behavior of being callable but reporting typeof == 'object' is required for compatibility (it is clear that NodeLists actually being callable is).

There is much more discussion in the bug.

Regards,
Maciej


Reply via email to