- From: Tab Atkins Jr. <jackalmage@gmail.com>
- Date: Tue, 7 Oct 2014 10:32:38 -0700
- To: "L. David Baron" <dbaron@dbaron.org>
- Cc: Benjamin Poulain <bpoulain@apple.com>, www-style list <www-style@w3.org>
On Mon, 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. It's definitely unintended. I'll fix that. >> 2) Currently, the implementation generate a parsing error if pseudo elements are used within the nested selector list. The internal definition is the same as :not(). >> I believe this is the most useful definition for web developers as there is no added magic. Tab was in favor of silently ignoring pseudo elements. I would love to get more feedback on this. > > It's certainly consistent with existing selector behavior to give > an error; I prefer it for at least that reason. I was not in favor of silently ignoring pseudo-elements; I was arguing that having a pseudo-element in the selector is valid, it just makes the :nth-child() pseudo match nothing, because :nth-child() never applies to pseudo-elements. >> 3) The spec’s grammar does not cover :nth-child(An+B of selector). The current WebKit implementation make the selector list mandatory if the keyword “of” is present (e.g. :nth-child(2n of ) is invalid). The spec defines ":nth-child(An+B [of sel]?)” then say "If sel is omitted, it defaults to *.”. > > Requiring a nonempty selector after "of" sounds right to me. That's already implied by the grammar. The prose is not providing an exception to the grammar, it's specifying the default behavior when you (validly) omit sel, which you can only do if you also omit "of". ~TJ
Received on Tuesday, 7 October 2014 17:33:24 UTC