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

Re: typeof document.all

From: Ian Hickson <ian@hixie.ch>
Date: Tue, 14 Jul 2009 07:22:24 +0000 (UTC)
To: Boris Zbarsky <bzbarsky@MIT.EDU>
Cc: Simon Pieters <simonp@opera.com>, Maciej Stachowiak <mjs@apple.com>, Thomas Broyer <t.broyer@ltgt.net>, "public-html@w3.org" <public-html@w3.org>
Message-ID: <Pine.LNX.4.62.0907140717570.9397@hixie.dreamhostps.com>
On Mon, 13 Jul 2009, Boris Zbarsky wrote:
> 
> In Gecko, document.all is in fact on the prototype of the document.  
> More precisely, trying to use document.all (as opposed to just test for 
> it) changes the prototype chain of the document such that its prototype 
> has the "all" property.  Try this in your favorite Gecko-based browser:
> 
> <script>
>   var oldProto = document.__proto__;
>   alert(oldProto.hasOwnProperty("all"));
>   document.all.length;
>   alert(oldProto.hasOwnProperty("all"));
>   alert(document.__proto__.hasOwnProperty("all"));
>   alert(document.__proto__ == oldProto);
>   alert(document.__proto__.__proto__ == oldProto);
> </script>
> 
> You should be seeing alerts with the following values: false, false, 
> true, false, true

The "adding 'all' after it's used" behaviour doesn't match other browsers 
as far as I can tell.


> I have no idea what the spec is saying about this, exactly (link 
> appreciated), but document.hasOwnProperty("all") is false in Gecko, and 
> will continue to be so, I suspect; that's just not an own property of 
> that object.  The behavior is quite self-consistent, contrary to Thomas' 
> claim above.

http://www.whatwg.org/specs/web-apps/current-work/multipage/obsolete-features.html#dom-document-all

See also the IDL block above it (which defines the prototype) and the 
definition of HTMLAllCollection linked to from that section that defines 
the variant of HTMLCollection used for this API (and for col.tags()).

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Tuesday, 14 July 2009 07:23:01 UTC

This archive was generated by hypermail 2.3.1 : Thursday, 29 October 2015 10:15:48 UTC