W3C home > Mailing lists > Public > www-style@w3.org > April 2012

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

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Mon, 30 Apr 2012 09:56:57 -0700
Message-ID: <CAAWBYDCv=NoFRd68VRCE1oxzgJvBEfx+d4ymeCdhNjXZg-Hi5A@mail.gmail.com>
To: "Kang-Hao (Kenny) Lu" <kennyluck@csail.mit.edu>
Cc: WWW Style <www-style@w3.org>
On Mon, Apr 30, 2012 at 9:06 AM, Kang-Hao (Kenny) Lu
<kennyluck@csail.mit.edu> wrote:
> The prose for this part, used for :nth-child, etc., is
>
>  # The argument to :nth-child() must match the grammar below, where
>  # INTEGER matches the token [0-9]+ and the rest of the tokenization
>  # is given by the Lexical scanner in section 10.2:
>  #
>  # nth
>  #    : S* [ ['-'|'+']? INTEGER? {N} [ S* ['-'|'+'] S* INTEGER ]? |
>  #           ['-'|'+']? INTEGER | {O}{D}{D} | {E}{V}{E}{N} ] S*
>  #    ;
>
> . This couldn't quite explain why ":nth-child(1/**/n)" is ignored in all
> the browsers I tested (IE9, Firefox 12, Chromium 18, Opera12alpha) with
> a case like
>
>  data:text/html,<style>body:nth-child(1/**/n) { color: red; }</style>Test
>
> . Should we consider this browser bugs or should the spec match browsers
> here?

Or, wait.  Actually, this grammar is busted.  It is impossible to scan
the above, since "1n" will already have been tokenized as a DIMENSION.
 Possibly browsers handle that implicitly, and *actually* match a
grammar something like:

  <dimension> [ [ + | - ] <integer> ]?
| <keyword> [ [ + | - ] <integer> ]?
| <integer>
| odd
| even

...with checks that the DIMENSION and KEYWORD are just 'n'.

So, this is a Selectors bug, not a browser bug.  We can't blame
browsers for failing to do an impossible thing.  ^_^

~TJ
Received on Monday, 30 April 2012 16:57:45 UTC

This archive was generated by hypermail 2.4.0 : Monday, 23 January 2023 02:14:14 UTC