<?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>14743</bug_id>
          
          <creation_ts>2011-11-09 18:47:16 +0000</creation_ts>
          <short_desc>Indexing NodeList out of range should return undefined</short_desc>
          <delta_ts>2011-11-09 20:04:04 +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>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</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="Aryeh Gregor">ayg</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>mike</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>59790</commentid>
    <comment_count>0</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-11-09 18:47:16 +0000</bug_when>
    <thetext>Try this on Live DOM Viewer:

&lt;!DOCTYPE html&gt;
&lt;script&gt;
try {w(document.childNodes[-1])} catch(e) {w(e)}
try {w(document.childNodes.item(-1))} catch(e) {w(e)}
try {w(document.childNodes[20])} catch(e) {w(e)}
try {w(document.childNodes.item(20))} catch(e) {w(e)}
&lt;/script&gt;

IE9: undefined, null, undefined, null
Firefox 9.0a2: INDEX_SIZE_ERR, null, undefined, null
Chrome 16 dev: undefined, INDEX_SIZE_ERR, undefined, null
Opera 12.00: undefined, null, undefined, null

Correct behavior is clearly IE/Opera, IMO.  Throwing anywhere here is annoying because it means you can&apos;t use if (document.childNodes[i]) to test whether the child exists.

The current spec says NodeList.prototype.item is a getter, and therefore as far as I can tell its behavior has to match actual indexing per WebIDL.  The correct fix is probably to make item() not a getter, and define separate getting behavior that returns undefined.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>59795</commentid>
    <comment_count>1</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-11-09 20:04:04 +0000</bug_when>
    <thetext>Hixie pointed me to the correct part of WebIDL.  I think it contradicts the parts I was looking at, so I&apos;ll file some WebIDL bugs, but DOM4 is correct, anyway.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>