W3C home > Mailing lists > Public > public-webapi@w3.org > February 2008

[selectors-api] Clarification about ElementSelector.querySelectorAll's scope

From: Kartikaya Gupta <kagupta@rim.com>
Date: Tue, 19 Feb 2008 09:58:22 -0500
Message-ID: <24BE9C481C439C48831EB9E52639B9B60A8D484E@XCH42YKF.rim.net>
To: <public-webapi@w3.org>
>From reading the spec, it wasn't immediately clear to me which of the
following two cases applies to element.querySelectorAll (and similarly
to element.querySelector):

 

1.	The nodes returned are the nodes that match
document.querySelectorAll AND are contained within the subtree rooted at
the element.
2.	The nodes returned are the nodes that match the group of
selectors if the selection algorithm is run only on the subtree rooted
at the element.

 

Put as an example (which is probably clearer), with the following
document:

 

<html>

 <body>

  <div id="foo">

   <a
href="javascript:alert(document.getElementById('foo').querySelector('bod
y a'));">test</a>

  </div>

 </body>

</html>

 

If case (1) applies, then the querySelector should match the anchor tag
and the dialog should show [object HTMLAnchorElement]. If case (2)
applies, then since there is no "body" tag within the <div id="foo">,
nothing will match and the alert dialog will show null. None of the
browser versions I currently have installed support querySelector yet,
so I couldn't check against their implementations.

 

Any clarification would be appreciated.

 

Thanks,

Kartikaya Gupta


---------------------------------------------------------------------
This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.
Received on Tuesday, 19 February 2008 14:58:38 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 19 February 2008 14:58:39 GMT