W3C home > Mailing lists > Public > public-html@w3.org > June 2009

Re: typeof document.all

From: Maciej Stachowiak <mjs@apple.com>
Date: Fri, 19 Jun 2009 00:38:34 -0700
Cc: Simon Pieters <simonp@opera.com>, "public-html@w3.org" <public-html@w3.org>
Message-id: <27387EBA-19DA-4A57-BA91-7FFF72E7AE37@apple.com>
To: Maciej Stachowiak <mjs@apple.com>

On Jun 19, 2009, at 12:27 AM, Maciej Stachowiak wrote:

>
> On Jun 19, 2009, at 12:03 AM, Simon Pieters wrote:
>
>> There is interop between Opera, WebKit and Firefox that typeof  
>> document.all returns 'undefined'. I think this is needed for Web  
>> compat.
>
> I think all non-IE browsers that implement document.all go to  
> elaborate lengths to make various tests for it fail - the idea is to  
> provide it for pages that use it unconditionally, but stop pages  
> that test for it from going into an IE-specific code path. However,  
> as far as I can tell HTML5 doesn't spec document.all at all, so I'm  
> not sure it's relevant for the spec to describe these things.

I was wrong, it does spec it. Here are the special behaviors WebKit  
ensures for document.all:

- document.all is false when tested in a boolean comparison, so if  
(document.all) checks fail
- the following expression evaluates to true: document.all == undefined
- the following expression evaluates to true: document.all == null
- the following expression evaluates to false: document.all != undefined
- the following expression evaluates to false: document.all != null
- the expression "typeof document.all" returns the string "undefined"
- the expression !document.all evaluates to true

Note that these are all impossible for a normal JavaScript object  
following the ECMAScript spec. However, the ECMAScript spec allows  
host objects to do essentially anything.

One thing we do not do is affect the behavior of === and !== (the  
strict equality and strict inequality operators).

I am not sure exactly which of these rules are needed for Web  
compatibility.

Regards,
Maciej
Received on Friday, 19 June 2009 07:40:16 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 9 May 2012 00:16:38 GMT