<?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>16488</bug_id>
          
          <creation_ts>2012-03-23 07:57:36 +0000</creation_ts>
          <short_desc>Consider adding parent() / ancestor() method</short_desc>
          <delta_ts>2014-05-26 14:25:59 +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 3.1</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="Anne">annevk</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>dhtmlkitchen</cc>
    
    <cc>erik.arvidsson</cc>
    
    <cc>hasather</cc>
    
    <cc>lachlan.hunt</cc>
    
    <cc>mike</cc>
    
    <cc>ojan</cc>
    
    <cc>sebastianzartner</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>65971</commentid>
    <comment_count>0</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2012-03-23 07:57:36 +0000</bug_when>
    <thetext>The method either takes a function or a selector. While walking up the parent chain from the node on which the method was invoked, If the function returns true or the selector matches for the current node, it is returned, or null otherwise.

Suggestion from Ojan.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78579</commentid>
    <comment_count>1</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2012-11-21 18:45:43 +0000</bug_when>
    <thetext>Lachy, this might be something you&apos;re working on?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79110</commentid>
    <comment_count>2</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2012-11-29 11:47:34 +0000</bug_when>
    <thetext>Okay, so basically this is the method that is desired:

Element.prototype.ancestor = function(selector) {
  var node = this
  while((node = node.parent) &amp;&amp; node.nodeType == Node.ELEMENT_NODE)
    if(node.matches(selector))
      return node
  return null
}

Correct?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89387</commentid>
    <comment_count>3</comment_count>
    <who name="David Håsäther">hasather</who>
    <bug_when>2013-06-17 10:11:22 +0000</bug_when>
    <thetext>Anne, I think a method that returns the element itself or an ancestor (what the specification calls an _inclusive ancestor_) would be more useful. This is typically what you want when doing event delegation.

The method name inclusiveAncestor() is not optimal though, so it would need some thinking.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106655</commentid>
    <comment_count>4</comment_count>
    <who name="David Håsäther">hasather</who>
    <bug_when>2014-05-22 15:03:32 +0000</bug_when>
    <thetext>jQuery and Dojo calls this closest(): http://api.jquery.com/closest/&gt; and http://dojotoolkit.org/reference-guide/1.9/dojo/NodeList-traverse.html#closest

Tab also suggested closest() a while ago: http://lists.w3.org/Archives/Public/www-style/2014Jan/0051.html

It&apos;s not a verb, but neither is before() and after() for example.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106798</commentid>
    <comment_count>5</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-05-26 14:25:48 +0000</bug_when>
    <thetext>https://github.com/whatwg/dom/commit/fd69cc7ed9251d12b1185b24e6f89d3f0481f39d

Thanks David, hope you&apos;re enjoying your time off :-)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>