Re: typeof document.all

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 UTC