<?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>23694</bug_id>
          
          <creation_ts>2013-10-31 22:27:05 +0000</creation_ts>
          <short_desc>Should element.getElementById() consider the element itself when searching</short_desc>
          <delta_ts>2013-11-03 23:48:27 +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>Linux</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="Olli Pettay">bugs</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>bzbarsky</cc>
    
    <cc>glenn</cc>
    
    <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>95640</commentid>
    <comment_count>0</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2013-10-31 22:27:05 +0000</bug_when>
    <thetext>It is odd if getElementById can&apos;t be used reliably in a disconnected
subtree to find element by id.

Based on testing querySelector seems to have similar oddity, but
we don&apos;t need to copy its behavior here, IMO.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95647</commentid>
    <comment_count>1</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-11-01 00:08:20 +0000</bug_when>
    <thetext>SVGSVGElement.getElementById does _not_ consider the element itself.  Do we really want to break compat there?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95648</commentid>
    <comment_count>2</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-11-01 00:08:49 +0000</bug_when>
    <thetext>A possibility is to add an optional boolean argument, defaulting false, for whether to include the root, I guess...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95671</commentid>
    <comment_count>3</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2013-11-01 11:49:12 +0000</bug_when>
    <thetext>None of the getElement* methods behave this way. Ask web developers, they&apos;ll expect it to search among the descendants, not inclusive descendants.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95673</commentid>
    <comment_count>4</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2013-11-01 11:57:46 +0000</bug_when>
    <thetext>http://www.w3.org/TR/SVG/struct.html#__svg__SVGSVGElement__getElementById is vague, but implementations indeed don&apos;t include the root element of a subtree.
So, I guess we need to live with that oddity, and perhaps
add the boolean param later if needed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95744</commentid>
    <comment_count>5</comment_count>
    <who name="Glenn Maynard">glenn</who>
    <bug_when>2013-11-03 23:48:27 +0000</bug_when>
    <thetext>We only &quot;expect&quot; it to because we&apos;ve been bit by it and learned its weird behavior.  That doesn&apos;t mean it&apos;s how we *want* it to behave.

This can&apos;t be changed now, of course, but I definitely recall being annoyed at querySelector not matching the top element, and having to manually matchSelector it separately.  I don&apos;t know if it&apos;s worth adding a parameter, though (if so, it should be a dictionary parameter and not a bare boolean).

(If we add a function to search up the tree, eg. &quot;find the nearest container that matches a selector&quot;, it absolutely needs to check the initial node, though.)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>