W3C home > Mailing lists > Public > public-webapi@w3.org > January 2007

Re: Selectors API: Multiple elements with the same ID

From: Maciej Stachowiak <mjs@apple.com>
Date: Sun, 28 Jan 2007 14:58:51 -0800
Message-Id: <32E4FA84-8972-41CC-81F4-EE378B50205D@apple.com>
Cc: Robert Sayre <sayrer@gmail.com>, Anne van Kesteren <annevk@opera.com>, Bjoern Hoehrmann <derhoermi@gmx.net>, Simon Pieters <zcorpan@gmail.com>, "public-webapi@w3.org" <public-webapi@w3.org>
To: Boris Zbarsky <bzbarsky@mit.edu>


On Jan 27, 2007, at 7:56 PM, Boris Zbarsky wrote:

>
> Robert Sayre wrote:
>> MSDN says it returns the "first object".
>> <http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/ 
>> getelementbyid.asp>
>
> For what it's worth, that's not what Gecko does, and I personally  
> would rather not try to enforce that -- it's somewhat expensive to  
> do so in the face of DOM mutations.

I tried to make some test cases to figure out the difference (in  
current WebKit sources we changed to return the first match in  
document order to match IE, and, we thought, Firefox), but Gecko's  
getElementById seems to be really buggy. For instance, this alerts null:

<div id="foo">
</div>
<script>
alert(document.getElementById("foo"));
</script>

This is with Firefox 2.0.0.1 on Mac OS X. What am I doing wrong here?

Regards,
Maciej
Received on Sunday, 28 January 2007 22:59:29 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:18:56 GMT