Re: [selectors4][css3-syntax] an+b corner case

On 4/30/12 12:49 PM, Tab Atkins Jr. wrote:
>>   # nth
>>   #    : S* [ ['-'|'+']? INTEGER? {N} [ S* ['-'|'+'] S* INTEGER ]? |
>>   #           ['-'|'+']? INTEGER | {O}{D}{D} | {E}{V}{E}{N} ] S*
>>   #    ;
>
> It's a browser bug.  To restrict it in the Grammar, we'd have to have
> context-sensitive placement of comments.

Well, hold on.  You're already doing context-sensitive stuff going on 
here, no?  In particular, 1n is a single DIMENSION token, not an INTEGER 
token followed by the symbol N, per 
http://www.w3.org/TR/css3-selectors/#lex as far as I can tell.  So what 
this prose is saying is that inside the value of the :nth-* pseudos a 
completely different tokenizer from the one used for the rest of 
Selectors must be used, if I understand it correctly.

What you _could_ do instead, if desired, is to use the same tokenizer 
but instead of "INTEGER? {N}" use "{N} | DIMENSION" and require that the 
ident in the DIMENSION be "n".  Or define a token similar to the 
PERCENTAGE token as "{num}{N}" and use that token.

Of course in that case the behavior would just happen to match what 
browsers do right now, without any need for preserving comment tokens, 
or anything like that.

-Boris

Received on Monday, 30 April 2012 17:07:44 UTC