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

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. 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.

</Daniel>
--
Co-Chair, W3C CSS WG

Received on Friday, 28 March 2008 17:56:18 UTC