Re: [css-selectors] Proposal: Logical Combinators / Sets

On Wed, 2013-03-13 at 12:20 -0400, Brian Kardell wrote:
[...]
> .person:allOf( [occupation='designers'] *, [country='US'] *).unemployed{
> .... }


Your example shows that it's going to be easy to simulate look-ahead,
which stalls progressive rendering. People do that today anyway, using
jQuery or other libraries, but providing the common cases in forms that
are easily optimized seems to be a win, so I think some more work would
be needed here.

A minor comment - I'd prefer
.person:when( [occupation='designers'] * and [country='US'] *).unemployed

I think this is similar to the following XPath expression:

*[
  class("person")
  and class("unemployed")
  and @occupation = 'designers'
  and @country = 'US'
]

but I'm not certain of the role of the asterisks in your example. It
might be
*[
  .//*[class("person")]
  and .//*[class("unemployed")]/*
  and .//*[@occupation = 'designers']/*
  and .//*[@country = 'US']
]
but that makes no sense to me: your examples in your blog post didn't
make it clearer to me whether, for example, the selectors in your new
expressions apply to the element being matched or to its children or to
arbitrary descendants.

One of the difficulties with taking CSS selectors, which is a relatively
ad-hoc syntax, and extending it, is that you end up with difficult
corner cases or expressions that are hard to understand. Of course, we
had a similar problem with making XPath 2, although to a smaller extent
as XPath 1 already had an expression language.

But at some point it's worth asking, "are we keeping CSS selectors
simple, with general fallback to JacaScript (or XPath), or are we making
CSS too complicated?"

Liam

PS: I used class("str") as a convenience function short for
    contains(concat(" ", @class, " "), concat(" ", "str", " "))

    This is the sort of extension function I'd expect a Web browser to
    provide, along with tests like hover(), in a world in which XPath
    was a first-class citizen :-)

-- 
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org freenode/#xml

Received on Wednesday, 13 March 2013 18:25:26 UTC