<?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>16919</bug_id>
          
          <creation_ts>2012-05-03 14:25:49 +0000</creation_ts>
          <short_desc>Make element traversal members available on more nodes</short_desc>
          <delta_ts>2012-11-27 18:40:55 +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>FIXED</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="Simon Pieters">zcorpan</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>bugs</cc>
    
    <cc>erik.arvidsson</cc>
    
    <cc>jonas</cc>
    
    <cc>mike</cc>
    
    <cc>mtanalin</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>67289</commentid>
    <comment_count>0</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2012-05-03 14:25:49 +0000</bug_when>
    <thetext>If you have foo and want the next element sibling, it makes sense to just use nextElementSibling even if foo is not an element. Currently nextElementSibling is only defined on Element. The same argument goes for the other element traversal members.

Specifically, I think the following makes sense:

children
firstElementChild
lastElementChild
childElementCount
on Document, DocumentFragment, Element

previousElementSibling
nextElementSibling
on DocumentType, Element, CharacterData

I think this is similar to the new mutation methods (prepend() et al).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>67292</commentid>
    <comment_count>1</comment_count>
    <who name="Marat Tanalin | tanalin.com">mtanalin</who>
    <bug_when>2012-05-03 15:38:51 +0000</bug_when>
    <thetext>Reasonable.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78135</commentid>
    <comment_count>2</comment_count>
    <who name="Erik Arvidsson">erik.arvidsson</who>
    <bug_when>2012-11-09 17:19:33 +0000</bug_when>
    <thetext>Wouldn&apos;t previousElementSibling and nextElementSibling be useful on Node too?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78136</commentid>
    <comment_count>3</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2012-11-09 17:27:48 +0000</bug_when>
    <thetext>Node - (DocumentType, Element, CharacterData) = (Document, DocumentFragment), so probably not?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78137</commentid>
    <comment_count>4</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2012-11-09 17:28:05 +0000</bug_when>
    <thetext>But it sounds like in general you think this is a good idea?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78138</commentid>
    <comment_count>5</comment_count>
    <who name="Erik Arvidsson">erik.arvidsson</who>
    <bug_when>2012-11-09 18:00:26 +0000</bug_when>
    <thetext>(In reply to comment #4)
&gt; But it sounds like in general you think this is a good idea?

Yes. It sounds like an improvement.

The reason why I think nextElementSibling makes sense for all Nodes is that it would give the next sibling node that is an Element. Conceptually nextElementSibling is just:

Object.defineProperty(Node.prototype, &apos;nextElementSibling&apos;, {
  get: function() {
    for (var next = this.nextSibling;
         next &amp;&amp; next.nodeType !== Node.ELEMENT_NODE;
         next = next.nextSibling);
    return next;
  },
  ...
});</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78139</commentid>
    <comment_count>6</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2012-11-09 18:23:22 +0000</bug_when>
    <thetext>Maybe comment 3 was too cryptic. Simon is proposing to put previousElementSibling and nextElementSibling on all nodes, except for Document and DocumentFragment, where they are never useful, I think.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78937</commentid>
    <comment_count>7</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2012-11-27 18:40:55 +0000</bug_when>
    <thetext>https://github.com/whatwg/dom/commit/4522273382af5950d19154e5bfa74d2ab8566033</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>