W3C home > Mailing lists > Public > www-style@w3.org > March 2012

Re: [selectors4] Should the reference combinator really be a combinator?

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 7 Mar 2012 13:29:33 -0800
Message-ID: <CAAWBYDBdpRiFHqXTPfH-voEhhaF-SXaRbkaVdusRUrqu_HDYBg@mail.gmail.com>
To: Christopher Jeffrey <chjjeffrey@gmail.com>
Cc: www-style@w3.org
On Tue, Mar 6, 2012 at 5:12 PM, Christopher Jeffrey
<chjjeffrey@gmail.com> wrote:
> Hi,
>
> I maintain a selector engine written in javascript[1]. I initially
> didn't realize how awkward the reference combinator[2] was until I
> tried to implement it.
>
> The problem was apparent after I wrote the first implementation: every
> combinator represents some kind of positional relationship between two
> elements. The reference combinator, on the other hand, does not. An
> element that references another could be located anywhere in the tree.
> This requires a kind of hacky workaround to implement; a special case,
> just for the reference combinator. It's awkward to implement and
> awkward to understand. It doesn't really fit the description of a
> combinator. The syntax is strange, as well as inconsistent with the
> combinators we've known for years, and I'm sure it's confusing even to
> long time css users who are seeing it for the first time.
>
> On top of all this, there's the question of how practical and useful
> it would be in reality. Would the average css user ever touch this
> combinator, aside from the occasional label/input use-case?
>
> I just want to spark some discussion about this.
>
> [1]: https://github.com/chjj/zest
> [2]: http://www.w3.org/TR/selectors4/#idref-combinators

Combinators don't represent positional relationships, per se - they
represent some sort of logical relationship.  A combinator is just a
mapping operation over the set of currently matched elements.
(Selectors are filtering operations over the set.) Positional
relationships happen to be very useful and generally cheap,
particularly when processing selectors "backwards" like most engines
do.

There are some other relationships that we could potentially express
as combinators but have instead chosen to represent as pseudoclasses,
such as :col(), but that's because the relationship there is very
specific to HTML (and other languages that have tables which are
represented in row-major form, plus childless column elements) and not
general-purpose.  The reference combinator is potentially
multi-purpose.

~TJ
Received on Wednesday, 7 March 2012 21:30:22 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 22 May 2012 03:48:51 GMT