[csswg-drafts] [cssom][css-escape][css-selectors]: Using CSS.escape with nth-child

jridgewell has just created a new issue for https://github.com/w3c/csswg-drafts:

== [cssom][css-escape][css-selectors]: Using CSS.escape with nth-child ==
We've just gone though our codebase to enforce using `CSS.escape` on any dynamic parts of a selector. The only caveat we've found so far is with `:nth-child` and friends, due to the very limited set of parsing of [An+b](https://drafts.csswg.org/css-syntax-3/#anb-microsyntax)

```js
// Works fine
querySelector(`div.${CSS.escape(3)}`);

// Throws parse error
querySelector(`div:nth-child(${CSS.escape(3)})`);
```

Is `CSS.escape` meant to handle this situation? Or, should the An+b syntax be loosened to allow escaped numbers?

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2306 using your GitHub account

Received on Tuesday, 13 February 2018 00:07:03 UTC