Re: [csswg-drafts] Allow -n in an-b, allow comments within +n and -n

The grammar *does* allow for `-n` and `-n+5`. Every single "group" of clauses has the first line handle a no-sign initial, the second handle an initial `+`, and the third handle an initial `-`.

What it doesn't allow is `-` and `n` to be separate tokens; since we're already requiring no spaces between the sign and the `n`, the only reason to parse them as separate tokens *on purpose* is to specifically allow comments between them. We can't avoid that for `+n`, because that parses as two tokens no matter what, but there's no particular reason to specifically allow `-/**/n` to work - it's just more effort for literally zero payoff.

Chrome does not allow this, by the way: 

```html
<!DOCTYPE html>
<p>foo<p>foo<p>foo
<style>p:nth-child( -/**/n + 2 ) { color: red; }</style>
```

doesn't turn anything red, while `+/**/n + 2` does (correctly).  It looks like Firefox *does* allow it, giving the same effect as `-n + 2`, which I assume is because they don't follow the spec and instead just reparse the source text with a specialized an+b parser.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/pull/1498#issuecomment-306285984 using your GitHub account

Received on Monday, 5 June 2017 19:55:29 UTC