Re: typeof document.all

On Fri, 19 Jun 2009, 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.

On Fri, 19 Jun 2009, Maciej Stachowiak wrote:
> 
> 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 expression !document.all evaluates to true
> - 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"

I've required the above.


On Fri, 19 Jun 2009, Thomas Broyer wrote:
> 
> Doing some additional tests:
>  - Opera (9.64), FF (3.0.11) and Safari (4) all report document.all as
> [object HTMLCollection] in their JS console; Chrome (3) on the other
> hand reports it as undefined; however, all four browsers agree that
> document.all.toString() is "[object HTMLCollection]", it might just be
> how the JS console is implemented?

I've gone with the non-Chrome behaviour here.


>  - All four browsers return true for ("all" in document), I would have 
> expect a false here (this is explicitly allowed by ECMAScript, ยง8.6.2: 
> "Host objects may implement these methods in any manner unless specified 
> otherwise; for example, one possibility is that [[Get]] and [[Put]] for 
> a particular host object indeed fetch and store property values but 
> [[HasProperty]] always generates false.")

I've remained compatible with the deployed UAs on this.


>  - Opera and FF return false for document.hasOwnProperty("all"); this
> is inconsistent with the above, given that document.prototype is null
> (the property exists according to [[HasProperty]], it cannot be in the
> prototype chain as there is not prototype, but it doesn't exist on the
> object, so where is it?!) Chrome and Safari return true.

I've gone with the Chrome/Safari behaviour here.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Tuesday, 14 July 2009 05:00:36 UTC