W3C home > Mailing lists > Public > www-style@w3.org > February 2015

Re: [selectors] Proposal: :n-children() selector

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Thu, 5 Feb 2015 09:19:10 +1100
Message-ID: <CAAWBYDBRN9HWqSLtQJPXZ4cUNb3fVo30AjUwBW7SLmj_O5nH0A@mail.gmail.com>
To: Benjamin Poulain <benjamin@webkit.org>
Cc: Henrik Andersson <henke@henke37.cjb.net>, Matt Mastracci <matthew@mastracci.com>, Lea Verou <lea@verou.me>, www-style list <www-style@w3.org>
On Thu, Feb 5, 2015 at 5:50 AM, Benjamin Poulain <benjamin@webkit.org> wrote:
> On 2/4/15 1:33 AM, Tab Atkins Jr. wrote:
>> On Tue, Feb 3, 2015 at 9:15 PM, Henrik Andersson <henke@henke37.cjb.net>
>> wrote:
>>> Tab Atkins Jr. skrev:
>>>> So that writing `.foo:--n-siblings(3)` would become
>>>> `:nth-child(1):nth-last-child(3) /self-and-siblings/ .foo` after
>>>> expansion.
>>>
>>> Those selectors look scary. Simplicity helps authors get things right.
>>
>> You (or someone smarter than you that you're copy-pasting from) writes
>> them once.  Then you can use them in the simple way, like
>> `.foo:--n-children(5)`.  That's the whole point of custom selectors.
>
> What would be the specificity of :--n-children() in your example?

That is an excellent question, and one that I'm not sure about.
Probably we need some way to manually specify the specificity.  I
think the answer is always [0,1,0] (same as most pseudo-classes) or
the specificity of a selector.  I'll figure out how to indicate it in
the syntax; this would probably kick this over to wanting a block
syntax (naming the parts of it with descriptors) rather than a
statement syntax.

> If it is the specificity of the expansion, that would be hell to work with.

That's almost certainly not what'll happen.  No selector acts like that today.

~TJ
Received on Wednesday, 4 February 2015 22:19:57 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:52:01 UTC