- From: Mike Wilson <mikewse@hotmail.com>
- Date: Sun, 15 Mar 2009 22:56:13 +0100
- To: "'Boris Zbarsky'" <bzbarsky@MIT.EDU>
- Cc: "'www-style'" <www-style@w3.org>
Boris Zbarsky wrote on 15 mars 2009 18:05: > Mike Wilson wrote: > > Would it be desirable to instead count indexes based on > > the selected subset, like in: > > li.item:nth-child(odd) {background-color:grey;} > > <li>...</li> --> (not selected) > > <li class="item">a</li> --> index 1 = odd = grey > > <li class="item">b</li> --> index 2 = even > > <li class="item">c</li> --> index 3 = odd = grey > > ? > > Some thoughts off the top of my head: > > 1) I can see some use cases for that, but under a different name, > since the existing nth-child is pretty interoprably implemented > already; changing behavior at this point would involve changing > a bunch of selector engines, changing web pages that depend on > the current behavior (which has been specified for a while), and > so forth. Not the sort of change one makes in Last Call, in my > opinion... Certainly, and I was really just interested in what (if any) conclusions in this area had been made during the work on the spec. [My own role here is mainly being ignorant; I've known about nth-child and the others for a long time and have always expected them to work on the selected subset. It wasn't until now that I actually took a deeper look...] So, from the comments so far I gather that the main reason the selectors were not designed to work on the selected subset is because it was never suggested or discussed. I also gather that it could be a good idea to support something of the kind in the future. > 2) How does one define what the "selected subset" is? Are we > talking > about "children of the same parent that match the rest of the > selectors in this rule" or something along those lines? I guess I was expecting the subset to be the children that is the result of the simple selectors to the left of :nth-child within the same sequence, ie "li.item" and "li:not([title])" in these rules: ul.foo > li.item:nth-child(odd) ul.foo > li:not([title]):nth-child(odd) > If so, how does this work when multiple :nth-child or > :nth-of-type selectors are present? Dunno, but my head definitely starts spinning ;-) > It basically seems like this significantly > complicates > the existing "each chain of simple selectors matches the > intersection of the sets of nodes the individual simple > selectors > match" model CSS has right now. I feel I don't have enough insight in implementations, but I think I get your point that this selector couldn't do its job "standalone" from the other selectors in the sequence, but would rather be dependent on the result from the selectors to the left of itself, before being able to return its own result. Maybe that is a major problem? Best regards Mike
Received on Sunday, 15 March 2009 21:57:27 UTC