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

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