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

Re: [Element Traversal LC] access to element by index

From: Doug Schepers <schepers@w3.org>
Date: Fri, 28 Mar 2008 15:10:16 -0400
Message-ID: <47ED4298.2010809@w3.org>
To: Daniel Glazman <daniel.glazman@disruptive-innovations.com>
Cc: Boris Zbarsky <bzbarsky@MIT.EDU>, "Web APIs WG (public)" <public-webapi@w3.org>

Hi, Daniel-

Daniel Glazman wrote (on 3/28/08 1:55 PM):
> 
> Boris Zbarsky wrote:
> 
>> Daniel Glazman wrote:
>>>    myFooElement.querySelector("*:nth-child(3)") does NOT work since
>>>    there can be another 3rd child in traversal order before the
>>>    3rd child of myFooElement.
>>
>> Being devil's advocate for a sec, having a :scope pseudo-class or some 
>> such would help here, right?
>>
>>   myFooElement.querySelector(":scope > :nth-child(3)")
> 
> That would require an addition to the Selectors spec and that comes
> too late in the process of that spec. 

Selectors API is at the same point in the process as Element Traversal, 
Last Call; while the official Selectors LC period is over, there's been 
no WG decision about publication as CR.

Since Selectors API is meant to be a more comprehensive API than Element 
Traversal, I would expect it to be able to deal with this more general 
use case Daniel mentions, and personally would prefer to increase the 
comprehensive functionality of that spec over Element Traversal, which 
is meant to be more lightweight.


> I would recommend changing
> the Selectors API on document.querySelector and
> document.querySelectorAll to allow a second argument being a node or
> null. If it's a node, then the results simulate your :scope > SELEC
> above, the scope being that node and SEL being the selector passed as
> the 1st argument. If it's null, well, it does what it does today.


Regards-
-Doug Schepers
W3C Team Contact, SVG, CDF, and WebAPI
Received on Friday, 28 March 2008 19:10:48 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 28 March 2008 19:10:50 GMT