Re: Implementation feedback for :nth-child(An+B of selector)

On Mon, Oct 6, 2014 at 6:41 PM, Benjamin Poulain <bpoulain@apple.com> wrote:
> Thanks for the feedback!
>
> On Oct 6, 2014, at 1:50 PM, L. David Baron <dbaron@dbaron.org> wrote:
>> On Monday 2014-10-06 12:27 -0700, Benjamin Poulain wrote:
>>> Hi,
>>>
>>> I have added :nth-child(An+B of selector) to Webkit (for now as an experimental feature behind a flag but enabled by default in WebKit Nightly).
>>>
>>> I have the following feedback:
>>>
>>> 1) Because of the definition (An+B-1 matching the selectorList), it is almost always necessary to repeat the selectors outside and inside :nth-child(). Most cases look something like:
>>>    li[foo].bar:nth-child(2n+1 of li[foo].bar)
>>>
>>> I personally like the power given by that definition but it is counter intuitive to write selectors with it. In my opinion, it would be beneficial to have one example covering this aspect in the specification.
>>
>> I wonder if that's really what we want, though.  I tend to think
>> it's not.  (Just because the :nth-child() definitions were written a
>> certain way before we added the "of" feature doesn't mean that we
>> want to keep the formal definition the same way once it starts
>> mattering which of two choices [1] we take for how to write the
>> formal definition.)
>>
>> At the very least, I don't think the group discussed this when
>> agreeing to add the feature, and I think we should.
>
> I am very much divided on this.
>
> On one hand, the current definition allows for some cool stuff.
>
> For example, you can easily get any image appearing directly after the first paragraph and only the first paragraph:
>         img:nth-child(2 of p)
> or with no paragraph above:
>         img:nth-child(1 of p)

Being able to select a range *until* something else is something that
I think is useful, but should be addressed directly, rather than
smuggled in via a confusing and unintended syntax.  The same argument
applies to descendant selectors, for example - it's reasonable to want
to select all "img" descendants of a comment block, but not ones
nested inside of *further* comments.

~TJ

Received on Tuesday, 7 October 2014 17:37:33 UTC