<?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>17726</bug_id>
          
          <creation_ts>2012-07-09 20:23:45 +0000</creation_ts>
          <short_desc>Enumerables on lists</short_desc>
          <delta_ts>2012-11-21 18:58:09 +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>All</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>enhancement</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jonathan Neal">jonathantneal</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>bzbarsky</cc>
    
    <cc>erik.arvidsson</cc>
    
    <cc>mike</cc>
    
    <cc>ojan</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>69747</commentid>
    <comment_count>0</comment_count>
    <who name="Jonathan Neal">jonathantneal</who>
    <bug_when>2012-07-09 20:23:45 +0000</bug_when>
    <thetext>Should NodeList, DOMTokenLists, and other list enumerables behave like Array enumerables?

Right now, properties like &quot;length&quot;, &quot;item&quot;, &quot;add&quot;, &quot;remove&quot;, &quot;toggle&quot;, and &quot;contains&quot; are enumerable, which makes for (e in someList) not as zesty as for (e in someArray).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>69749</commentid>
    <comment_count>1</comment_count>
    <who name="Erik Arvidsson">erik.arvidsson</who>
    <bug_when>2012-07-09 21:28:52 +0000</bug_when>
    <thetext>It is considered bad practice to use for-in loops for arrays and array like objects.

FWIW, &quot;length&quot; is non enumerable in IE and Firefox. It is enumerable in WebKit/JSC, WebKit/V8 and Opera.

ES6 solves this using the for-of loop wich uses an iteration hook. http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts. The right thing to do is probably to spec that the default iterator of these things should be that same as Array.prototype.iterator. which would allow us to do:&quot;

for (var element of document.querySelectorAll(&apos;p&apos;)) {
  assert(element.tagName === &apos;P&apos;);
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>69762</commentid>
    <comment_count>2</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2012-07-10 06:45:34 +0000</bug_when>
    <thetext>Jonathan, &quot;for (e in someArray)&quot; is pretty broken, since it will enumerate all sorts of things in various cases.  Just don&apos;t go there.  ;)

Gecko+Spidermonkey already has support for for-of on lists.  And there&apos;s discussion about making that automatic in WebIDL.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78582</commentid>
    <comment_count>3</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2012-11-21 18:58:09 +0000</bug_when>
    <thetext>Jonathan, our plan of dealing with this is bug 17648. Hopefully that is okay with you. Please let me know if you have any concerns.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>