<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>17461</bug_id>
          
          <creation_ts>2008-02-20 15:38:27 -0800</creation_ts>
          <short_desc>querySelectorAll doesn&apos;t return correct nodes when using element in element patterns</short_desc>
          <delta_ts>2008-03-09 08:14:31 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>DOM</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</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>0</everconfirmed>
          <reporter name="Moxiecode Systems">spam</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>annevk</cc>
    
    <cc>aroben</cc>
    
    <cc>borgar</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>71323</commentid>
    <comment_count>0</comment_count>
    <who name="Moxiecode Systems">spam</who>
    <bug_when>2008-02-20 15:38:27 -0800</bug_when>
    <thetext>When using the querySelectorAll method on an element it doesn&apos;t return the correct number of nodes if a pattern with elements in elements are used.

For example if this code is executed on an element with 4 divs but only one div withing another div it should return 1 and not 4.

document.getElementById(&apos;test&apos;).querySelectorAll(&apos;div div&apos;);

HTML:
&lt;div id=&quot;test&quot;&gt;
	&lt;div&gt;1&lt;/div&gt;
	&lt;div&gt;
		&lt;div&gt;2&lt;/div&gt;
	&lt;/div&gt;
	&lt;div&gt;3&lt;/div&gt;
&lt;/div&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>71324</commentid>
    <comment_count>1</comment_count>
      <attachid>19242</attachid>
    <who name="Moxiecode Systems">spam</who>
    <bug_when>2008-02-20 15:40:28 -0800</bug_when>
    <thetext>Created attachment 19242
Testcase to illustrate the bug.

This test case will alert 4 but should alert 1 since only one div is inside another div.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>71325</commentid>
    <comment_count>2</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2008-02-20 15:53:18 -0800</bug_when>
    <thetext>I&apos;d mark this INVALID, but can&apos;t.

Anyway, selectors are always matched agains the document element. However, for calls on element nodes all nodes not part of the sub tree of that element node are filtered out. This is why you end up with 4 and not 1 or 5.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>71326</commentid>
    <comment_count>3</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2008-02-20 15:56:13 -0800</bug_when>
    <thetext>I shouild have mentioned that we will clarify the specification in due course to make this more explicit.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>71327</commentid>
    <comment_count>4</comment_count>
    <who name="Adam Roben (:aroben)">aroben</who>
    <bug_when>2008-02-20 15:56:49 -0800</bug_when>
    <thetext>Marking INVALID per Anne&apos;s comments.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>71328</commentid>
    <comment_count>5</comment_count>
    <who name="Moxiecode Systems">spam</who>
    <bug_when>2008-02-20 16:00:42 -0800</bug_when>
    <thetext>Hmm, strange since this is not the way common libraries like jQuery/Prototype etc work. They all return 1 if you scope the search to an specific element so this can&apos;t be used as an replacement for those APIs. I could not find anything about this in the W3C specification so I&apos;m wondering what is the correct behavior?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73120</commentid>
    <comment_count>6</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2008-03-09 08:14:31 -0700</bug_when>
    <thetext>*** Bug 17731 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>19242</attachid>
            <date>2008-02-20 15:40:28 -0800</date>
            <delta_ts>2008-02-20 15:40:28 -0800</delta_ts>
            <desc>Testcase to illustrate the bug.</desc>
            <filename>test.HTML</filename>
            <type>text/html</type>
            <size>208</size>
            <attacher name="Moxiecode Systems">spam</attacher>
            
              <data encoding="base64">PGh0bWw+DQo8Ym9keSBvbmxvYWQ9ImFsZXJ0KGRvY3VtZW50LmdldEVsZW1lbnRCeUlkKCd0ZXN0
JykucXVlcnlTZWxlY3RvckFsbCgnZGl2IGRpdicpLmxlbmd0aCk7Ij4NCg0KPGRpdiBpZD0idGVz
dCI+DQoJPGRpdj4xPC9kaXY+DQoJPGRpdj4NCgkJPGRpdj4yPC9kaXY+DQoJPC9kaXY+DQoJPGRp
dj4zPC9kaXY+DQo8L2Rpdj4NCg0KPC9ib2R5Pg0KPC9odG1sPg==
</data>

          </attachment>
      

    </bug>

</bugzilla>