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

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

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Thu, 14 Mar 2013 22:14:14 -0700
Message-ID: <CAAWBYDBm6AC-L6xu+k9Qo+CwLDx9vj7ocPYOH5oxOHTCytiPAA@mail.gmail.com>
To: Lea Verou <lea@w3.org>
Cc: Brian Kardell <bkardell@gmail.com>, "www-style@w3.org" <www-style@w3.org>
On Thu, Mar 14, 2013 at 4:19 PM, Lea Verou <lea@w3.org> wrote:
> I might be missing something here, but isn’t :anyof() essentially
> :matches(), :noneof() essentially :not() and :allof() essentially
> ...chaining of simple selectors (i.e. compound selectors)?

Yes, as long as they're limited to compound selectors.  As soon as we
allow complex selectors (which we want to do in :matches(), and once
that happens there's no reason we couldn't do so in :not() as well),
there are things you can't emulate with just that.

So, we don't need them all *yet*.  But we likely will eventually.
Thus, it makes sense to set up our current names to match with the
future names.  In particular, I think :matches() should be renamed
:any() or :any-of().  The former brings it back to Moz's original name
for it.


> Note that :not() has been extended in Selectors 4, and now supports compound
> selectors too [1].
> The only use cases I see that this covers are:
> 1. XOR, by :oneof()
> 2. Negation of complex selectors
> 3. Disjunction of complex selectors (as part of a larger selector, otherwise
> it can be done already with commas)
> 4. Intersection of complex selectors
> I’m not sure if #1 is really needed, and the example in your blog post isn’t
> exactly a real use case. #2 and #3 could be useful, and could be solved by
> allowing complex selectors in :not() and :matches(), no need for new
> pseudo-classes. However, I’d bet there was a good reason that we didn’t
> allow this, since it’s obvious from the spec text that it has been
> considered. #4 could be useful as well, but I’m pretty sure the reasons
> preventing #2 and #3 would apply to it too.
> [1]: http://www.w3.org/TR/selectors4/#negation
> Lea Verou
> W3C developer relations
> http://w3.org/people/all#leahttp://lea.verou.me ✿ @leaverou
> On Mar 8, 2013, at 03:39, Brian Kardell wrote:
> A recent discussion about adding Set operations on another list prompted me
> to discuss something to Tab which I've mulled around (even prollyfilled) in
> the past and think it's worth proposing...
> CSS selectors operate on _sets_ of elements, but until  recently
> (:matches/:not) we've had nothing in the way of logical selectors or any
> language constructs that hinted at set oriented language.   This seems a
> shame to me as sets and logic gates are some of the most powerful concepts
> in CS.  The relationship feels natural to me.
> This proposal would require us to get complex selectors inside, but
> essentially I am proposing some logical combinators like
> :anyof, :allof, :oneof, :noneof to act as predicates which allow some very
> rich selection.  Examples/more details in my blog post:
> http://briankardell.wordpress.com/2013/03/07/logical-psuedo-selectors-a-proposal/
> --
> Brian Kardell :: @briankardell :: hitchjs.com
Received on Friday, 15 March 2013 05:15:01 UTC

This archive was generated by hypermail 2.4.0 : Monday, 23 January 2023 02:14:25 UTC