[csswg-drafts] [selectors] Let :matches() have better error-recovery behavior than normal Selectors

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

== [selectors] Let :matches() have better error-recovery behavior than normal Selectors ==
This isn't captured in the current spec, but I remember earlier speculation that we could use `:matches()` as a way to get around the bad Selectors behavior of "a syntax error in one complex selector invalidates the whole sequence" that we're stuck with.  Do we still think this is a worthwhile idea to pursue?

Spec-wise, what this would mean is defining the official syntax as `:matches( <any-value> )`, then split the result on top-level comma tokens, then attempt to parse each item as a `<complex-selector>`, and just ignore any invalid ones. (If all of them are invalid, the selector matches nothing.)

Then, if you're concerned about using a newer feature, you can just write your selectors like:

```
:matches( .foo || .bar, td.foo:first-child ) {
  /* styles for the bar cell */
```

An unfortunately, but relatively minor, tax for getting better error-recovery behavior. (If we *do* end up renaming it to `:is()`, it's even more minor.)

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

Received on Monday, 29 October 2018 19:04:01 UTC