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

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 UTC