<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>22328</bug_id>
          
          <creation_ts>2013-06-11 17:50:39 +0000</creation_ts>
          <short_desc>HTMLAllCollection.namedItem doesn&apos;t match reality</short_desc>
          <delta_ts>2016-10-25 08:59:48 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>HTML WG</product>
          <component>HTML5 spec</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>MOVED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard>whatwg-resolved</status_whiteboard>
          <keywords></keywords>
          <priority>P1</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Travis Leithead [MSFT]">travil</reporter>
          <assigned_to name="Travis Leithead [MSFT]">travil</assigned_to>
          <cc>annevk</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>public-html-admin</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
    
    <cc>robin</cc>
    
    <cc>silviapfeiffer1</cc>
          
          <qa_contact name="HTML WG Bugzilla archive list">public-html-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>89099</commentid>
    <comment_count>0</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2013-06-11 17:50:39 +0000</bug_when>
    <thetext>This test case fails in all browsers that support document.all today (used to work in IE7, but IE8 changed behavior to be interoperable. The spec should be updated to match today&apos;s reality :-)

I think the current behavior is that of the generic HTMLCollection.namedItem.


&lt;!DOCTYPE HTML&gt;
&lt;html&gt;
 &lt;head&gt;
  &lt;title&gt;collection.namedItem(name or id) returns collection of items with name or id&lt;/title&gt;
  &lt;link rel=&quot;help&quot; href=&quot;http://www.w3.org/html/wg/drafts/html/master/infrastructure.html#htmlallcollection&quot; /&gt;
  &lt;script type=&quot;text/javascript&quot;&gt;
 window.onload = function () {
    try {
       if (2 == document.all.namedItem(&quot;myelem&quot;).length) {
          document.getElementById(&quot;testresult&quot;).innerHTML = &quot;Pass&quot;;
       }
    } catch (ex) {
       document.getElementById(&quot;testresult&quot;).innerHTML = &quot;Fail&quot;;
    }
 }
  &lt;/script&gt;
 &lt;/head&gt;
 &lt;body&gt;
  &lt;p&gt;Description: Verify the collection of items with given name is returned (namedItem)&lt;/p&gt;
  &lt;p&gt;Test passes if the word &quot;Pass&quot; appears below.&lt;/p&gt;
  &lt;a style=&quot;visibility: hidden&quot; name=&quot;myelem&quot;&gt;&lt;/a&gt;
  &lt;a style=&quot;visibility: hidden&quot; id=&quot;myelem&quot;&gt;&lt;/a&gt;
  &lt;div id=&quot;testresult&quot;&gt;Fail&lt;/div&gt;
 &lt;/body&gt;
&lt;/html&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90249</commentid>
    <comment_count>1</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-07-03 18:23:28 +0000</bug_when>
    <thetext>(Note that since this is filed on the HTMLWG, it&apos;s not on my pile.)

It&apos;s definitely not HTMLCollection.namedItem()&apos;s behaviour (try changing the name=&apos;&apos; attribute to id=&apos;&apos;). And at least some browsers match the spec (Firefox, for one). Seems better to maintain compatibility with IE6, which was the main browser targeted by code that uses document.all, than to change this again.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90710</commentid>
    <comment_count>2</comment_count>
    <who name="Silvia Pfeiffer">silviapfeiffer1</who>
    <bug_when>2013-07-13 10:33:31 +0000</bug_when>
    <thetext>assigning to Travis, since it&apos;s your bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91034</commentid>
    <comment_count>3</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2013-07-20 00:32:39 +0000</bug_when>
    <thetext>Behaviors:
1. given an index, zero or one element may be returned
2. given a name, zero or first matching name/id element may be returned
3. given a name, zero, one, or a collection of matching name/id elements may be returned

(I dusted off an IE6 for this--very nostalgic...)

Test Results: 

API                          Spec  IE6  IE8-IE10  Firefox  Chrome
---------------------------  ----  ---  --------  -------  ------
HTMLCollection.item           1    1&amp;3    1&amp;3       1        1
HTMLCollection.namedItem      2     3      2        2        2*
HTMLAllCollection.item       1&amp;3   1&amp;3    1&amp;3      n/a      1&amp;3
HTMLAllCollection.namedItem  1&amp;3    3      2       n/a       3

*Returns the _last_ matching item for some reason


These are interesting results to say the least. There may be something to say for splitting the behavior of HTMLAllCollection.namedItem from HTMLAllCollection.item, as that seems to be what browsers are doing. However, having what the spec defines is probably *over compatible* which isn&apos;t necessarily a bad thing. Given these results, I don&apos;t see a clear motivation to change the spec at this time. Implementations may still need time to solidify on the right behavior here, and the spec&apos;s current stance seems fine to me.

At this point, I&apos;m removing the CR keyword, as this should definitely not block the CR spec at this time.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>121043</commentid>
    <comment_count>4</comment_count>
    <who name="Michael[tm] Smith">mike</who>
    <bug_when>2015-06-16 10:19:01 +0000</bug_when>
    <thetext>Making this a higher priority to actively seek more feedback on from implementers and webdevs.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126134</commentid>
    <comment_count>5</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2016-04-25 22:39:57 +0000</bug_when>
    <thetext>HTML5.1 Bugzilla Bug Triage: Moved to Github issue: https://github.com/w3c/html/issues/120

To file additional issues please use the W3C HTML5 Issue tracker: https://github.com/w3c/html/issues/new Thanks!</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>