<?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>15201</bug_id>
          
          <creation_ts>2011-12-15 02:36:30 +0000</creation_ts>
          <short_desc>HTMLCollection.item(string) should act like namedItem(string)</short_desc>
          <delta_ts>2012-03-12 18:13:40 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>DOM</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Glenn Maynard">glenn</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>adrianba</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>mike</cc>
    
    <cc>Ms2ger</cc>
    
    <cc>travil</cc>
    
    <cc>www-dom</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>61584</commentid>
    <comment_count>0</comment_count>
    <who name="Glenn Maynard">glenn</who>
    <bug_when>2011-12-15 02:36:30 +0000</bug_when>
    <thetext>HTMLCollection.item(string) behaves like HTMLCollection.namedItem(string) in most cases.  (Two exceptions are O11.60 and IE9, only when multiple matches are found; see bug #15200.)  This should probably be specified.

Test at https://zewt.org/~glenn/test-htmlcollection.html; results at https://zewt.org/~glenn/test-htmlcollection-results.html.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61615</commentid>
    <comment_count>1</comment_count>
    <who name="Ms2ger">Ms2ger</who>
    <bug_when>2011-12-15 17:50:29 +0000</bug_when>
    <thetext>This is a bug that should be fixed in implementations IMO.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61617</commentid>
    <comment_count>2</comment_count>
    <who name="Glenn Maynard">glenn</who>
    <bug_when>2011-12-15 18:24:38 +0000</bug_when>
    <thetext>This is something every implementation does, so practically speaking, the bug is in the spec.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61618</commentid>
    <comment_count>3</comment_count>
    <who name="Ms2ger">Ms2ger</who>
    <bug_when>2011-12-15 18:33:36 +0000</bug_when>
    <thetext>Gecko doesn&apos;t.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61622</commentid>
    <comment_count>4</comment_count>
    <who name="Glenn Maynard">glenn</who>
    <bug_when>2011-12-15 19:18:31 +0000</bug_when>
    <thetext>It looks like the usual evil IDL casting confusing things.  Re-testing, the browsers with this behavior are IE6, IE7, IE9 and Chrome (WebKit untested).  It&apos;s less clear-cut, but the fact that IE8 appeared to have fixed this but it was reverted in IE9 makes me suspect the change broke pages.

https://zewt.org/~glenn/test-htmlcollection-item-strings.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61623</commentid>
    <comment_count>5</comment_count>
    <who name="Ms2ger">Ms2ger</who>
    <bug_when>2011-12-15 19:22:49 +0000</bug_when>
    <thetext>Adrian, can you tell us something about IE&apos;s behaviour here, or forward the question to the right person?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61633</commentid>
    <comment_count>6</comment_count>
    <who name="Adrian Bateman [MSFT]">adrianba</who>
    <bug_when>2011-12-15 22:15:05 +0000</bug_when>
    <thetext>Adding Travis to look at this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61636</commentid>
    <comment_count>7</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2011-12-15 23:30:26 +0000</bug_when>
    <thetext>Yep, it broke real pages.

In early IE9, we implemented the strict spec behavior. However, when several high-profile sites broke, we decided to just point the API implementation back to the IE7 code (not enough sites were using IE8 mode for this problem to manifest).

It&apos;s possible that as sites drop their IE-only code paths, that we&apos;ll be able to &quot;fix&quot; our implementation, but we have no plans to do so at the moment.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61658</commentid>
    <comment_count>8</comment_count>
    <who name="Ms2ger">Ms2ger</who>
    <bug_when>2011-12-16 13:53:45 +0000</bug_when>
    <thetext>I guess you can&apos;t share which sites this were?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61673</commentid>
    <comment_count>9</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2011-12-16 16:34:32 +0000</bug_when>
    <thetext>The only reason WebKit does this is to make document.all.item(string) work, because it uses the same code for document.all and other HTMLCollections, fwiw.

We (Gecko) have gotten no bug reports about this breaking pages, to my knowledge.  I can&apos;t speak for Opera.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61674</commentid>
    <comment_count>10</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2011-12-16 16:35:47 +0000</bug_when>
    <thetext>Travis, would you mind checking whether the breakage you observed on sites in IE9 was with document.all or with other HTMLCollections?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61684</commentid>
    <comment_count>11</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2011-12-16 19:07:11 +0000</bug_when>
    <thetext>It was document.all related.

We use HTMLCollection for document.all and other collections like document.anchors.

After we &quot;fixed&quot; item() to work like Firefox (as of 2 years ago), the problem was that:
document.all.item(&apos;foo&apos;) no longer found an element with id=&quot;foo&quot; in the document. Instead, the string &apos;foo&apos; was coerced into a number (0) and used as an index-lookup, returning the HTMLHtmlElement...

It turns out that trying to make the change at that time was a bad idea, as our old interop report shows:

(pass means that item() will lookup by string name--not index alone)

document.all.item(&apos;iframe&apos;)
* IE7 = pass
* IE8 = FAIL
* IE9 = FAIL
* Fx  = pass
* Ch  = pass
* Saf = pass
* Op  = pass

document.anchors.item(&apos;anchor2&apos;)
* IE7 = pass
* IE8 = FAIL
* IE9 = FAIL
* Fx  = FAIL (same as IE8 standards mode)
* Ch  = pass
* Saf = pass
* Op  = pass

I just re-checked the test with the current release of each Browser (results are the same except that IE9 was &quot;fixed&quot; and Opera factored their HTMLCollection out from their HTMLAllCollection:

Browser   document.all.item()  document.anchors.item()
========  ===================  =======================
IE9       pass                 pass
Firefox   pass                 FAIL 
Chrome    pass                 pass
Safari    pass                 pass
Opera     pass                 FAIL</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61687</commentid>
    <comment_count>12</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2011-12-16 19:49:07 +0000</bug_when>
    <thetext>OK, that makes sense.  I absolutely agree that document.all needs to do the weird string thing for web compat; that&apos;s bug 15184.  I&apos;m just not convinced that needs to extend to all HTMLCollections.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65362</commentid>
    <comment_count>13</comment_count>
    <who name="Ms2ger">Ms2ger</who>
    <bug_when>2012-03-12 18:13:40 +0000</bug_when>
    <thetext>From the results here:

http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1384
http://w3c-test.org/webapps/DOMCore/tests/submissions/Ms2ger/Element-children.html
https://zewt.org/~glenn/test-htmlcollection-item-strings.html

it appears Chrome / Opera / Gecko consistently handle item(str) per spec, so I don&apos;t think we should change the spec.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>