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

Re: typeof document.all

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Mon, 13 Jul 2009 22:55:47 -0700
Message-ID: <4A5C1DE3.6000100@mit.edu>
To: Ian Hickson <ian@hixie.ch>
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>
Ian Hickson wrote:
>On Fri, 19 Jun 2009, Thomas Broyer wrote:
>>  - 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.

I'm confused by this.  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

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.

-Boris
Received on Tuesday, 14 July 2009 05:57:04 UTC

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