On 15/04/2014 14:33, Gijs Kruitbosch wrote:
On 15/04/2014 14:21, Andreas Tolfsen wrote:
On 15/04/2014 11:17, Anne van Kesteren wrote:
It would be interesting to know what they use it for and why
querySelector() et al don't meet their needs, but there's no immediate
threat of what we have going away so it's not that important either.

There are a few use cases XPath caters for that CSS selectors can't do.
The two predominant ones that springs to mind are finding an element
based on its text content, and finding any element relative to its
parent (or ancestor).

I'm not sure what you mean here, but I was under the impression (nay, I
just tested and verified) that document.querySelector("#foo #bar") works
for finding an element based on its ancestor (or parent, if you use a
child rather than a descendant selector).

Consider something like

    //table/tr/td[contains(., "foo")/../td[2]/input

which will find the table cell containing the text "foo", then find the second cell in the same row with an input element.

A few other limitations I've been informed of are:

  - Complex conditional statements such as looking up all classes of A,
    but not A combined with B or A with C.

  - Subqueries such as //li[.//a], meaning all li elements that have a
    as a child or descendant.  Although possibly this is addressed by !
    in CSS4?

_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to