<?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>27623</bug_id>
          
          <creation_ts>2014-12-16 06:44:04 +0000</creation_ts>
          <short_desc>A node.index() method for the ChildNode interface?</short_desc>
          <delta_ts>2014-12-16 15:54:23 +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>WORKSFORME</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="Glen Huang">hey.hgl</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>donjjordan</cc>
    
    <cc>mike</cc>
    
    <cc>www-dom</cc>
    
    <cc>zcorpan</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>116366</commentid>
    <comment_count>0</comment_count>
    <who name="Glen Huang">hey.hgl</who>
    <bug_when>2014-12-16 06:44:04 +0000</bug_when>
    <thetext>Love the jquery-like ChildNode interface.

I wonder if it makes sense to add a node.index() method that returns the node&apos;s index. This would be very helpful when dealing with DOM ranges: range.setStart(node.parentNode, node.index())</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116367</commentid>
    <comment_count>1</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2014-12-16 07:47:45 +0000</bug_when>
    <thetext>Alternatively maybe we could tweak the APIs that use indexes as input to also allow nodes as input:

range.setStart(node.parentNode, node)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116368</commentid>
    <comment_count>2</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2014-12-16 07:48:58 +0000</bug_when>
    <thetext>Or range.setStart(node)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116369</commentid>
    <comment_count>3</comment_count>
    <who name="Glen Huang">hey.hgl</who>
    <bug_when>2014-12-16 07:52:04 +0000</bug_when>
    <thetext>This probably won&apos;t cut it, since sometimes

range.setEnd(node.parentNode, node.index() + 1); // or +2

is needed</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116370</commentid>
    <comment_count>4</comment_count>
    <who name="Glen Huang">hey.hgl</who>
    <bug_when>2014-12-16 08:12:38 +0000</bug_when>
    <thetext>It turns out we already have setStartBefore and the likes, which does exactly what Simon suggest.

I personally have no use for this method for now.

Not sure if should close the bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116384</commentid>
    <comment_count>5</comment_count>
    <who name="">donjjordan</who>
    <bug_when>2014-12-16 15:54:23 +0000</bug_when>
    <thetext>Since a node.index() function is required by many of the DOM&apos;s internal algorithms (i.e. https://dom.spec.whatwg.org/#concept-tree-index), all of the DOM implementations already have a privately-defined method like this. If a use is ever found for this function outside of what is already provided by the DOM, then node.index() would be a freebie to expose in the IDL. For now, there is no point in cluttering up the API.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>