W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2012

Re: [dom] Should the return values of getElementsByClassName/TagName/TagNameNS be HTMLCollection

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Wed, 18 Jan 2012 11:37:07 -0500
Message-ID: <4F16F533.50604@mit.edu>
To: www-dom@w3.org
On 1/17/12 1:24 AM, Boris Zbarsky wrote:
> The current IDL says that these return NodeList. We have people who'd
> like to align Gecko with that, but I have a slight concern about it. In
> particular:
>
> 1) Gecko has returned HTMLCollections from these methods for a long time.
> 2) IE returns HTMLCollections from these methods.
> 3) Opera returns NodeLists from these methods, but Opera has a namedItem
> method on NodeList.prototype

One more data point:

   <!DOCTYPE html>
   <div id="x"></div>
   <script>
     alert(document.getElementsByTagName("*").x);
   </script>

alerts "[object HTMLDivElement]" across all browsers (tested Safari, 
Chrome, Firefox, Opera, IE9).  This is not what the spec says to do at 
the moment.  I strongly suspect that what the spec does say is not 
web-compatible.

Given that, I have no plans to change Gecko behavior here until the spec 
gets sorted out to say something sane.

-Boris
Received on Wednesday, 18 January 2012 16:37:38 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:14:09 GMT