Re: [csswg-drafts] [selectors] Functional pseudo-class like :matches() with 0 specificity

I'm convinced by this reasoning; in particular, that "div, but minus these three specific ones" should be capable of being overridden reasonably, instead of blowing up to a 3-ID specificity.

Do we want to stick with this "something that makes its contents specificity-0", or try and generalize this to solve specificity hacks more generally?  I'm not 100% sure how we'd do the latter in a future-friendly way (we've gone back and forth with precisely how many categories are in "specificity"), but I guess just sticking with the Big Three would be fine. (When we've tried to insert something else, it's for significant semantic differences, like scoped vs not, or inline vs not.)

Hmm. If we simplify and say that it has to be a compound selector only, then the grammar's pretty easy; if you want more complexity, you just nest a `:matches()` in.  I think I'm in favor of the simple, short `:is()` naming, as this is more-or-less a no-op wrapper; *every* selector is an "is" filter already.  Then you could control specificity like `:is(.foo, 1 2 3)` to give it the specificity of 1 ID, two attrs, and 3 tagnames.  Leaving the specificity off defaults it to `0 0 0`.

(I suppose we could allow a full complex selector, as commas don't interfere with that, and just require :matches() if you want a selector list.  But maybe good to keep it simple - it's just a modifier to a single selector. We let you do a full compound selector, rather than limiting to a single simple, to avoid verbosity in a common case - `.foo:is(.bar):is(.baz)` is identical in meaning to `.foo:is(.bar.baz)`, no reason to require more parens than necessary there.)

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

Received on Friday, 15 September 2017 19:29:14 UTC