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

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

From: Daniel Glazman <daniel.glazman@disruptive-innovations.com>
Date: Fri, 28 Mar 2008 17:55:50 +0100
Message-ID: <47ED2316.9090508@disruptive-innovations.com>
To: Doug Schepers <schepers@w3.org>
Cc: "Web APIs WG (public)" <public-webapi@w3.org>

Ok, guys, let's see it that way : we have one given element and we
want to find its 3rd element child. Very simple and common query,
right ?

1. using my proposal :


2. using Selectors API :

    myFooElement.querySelector("*:nth-child(3)") does NOT work since
    there can be another 3rd child in traversal order before the
    3rd child of myFooElement. I have no way of querying the 3rd child
    of myFooElement alone if myFooElement has no ID, no class, nothing
    since the :root pseudo-class does NOT apply to myFooElement in such
    a query but still represents the root of the document.
    Querying  :first-child+*+*  does not work either for the same reason,
    there can be a 3rd child deep in the subtree being before the 3rd
    child of myFooElement in traversal order of the document...

    This is a limitation of the Selectors API I detected long ago.
    Mentioned it a few times, too.

3. using XPath :

    document.evaluate('*[3]', myFooElement, null,

How much do you bet that if you show this to web designers, they'll
find solution (1) usable and will probably SCREAM LOUDLY at
(2) and (3) ?

Received on Friday, 28 March 2008 16:56:23 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:16:25 UTC