3 ms·
EDIT: I'm wrong, see [2] One of the big changes here is that the :has selector is available in regular stylesheets. This is going to open up a wonderful array
by mmastrac 10y ago
EDIT: I'm wrong, see [2]
One of the big changes here is that the :has selector is available in regular stylesheets. This is going to open up a wonderful array of interesting possibilities (virtual selectors like "parent of" or "previous sibling", for example).
When I last reviewed the spec [1], it was limited to use in JS querySelector*() calls only.
[1] https://grack.com/blog/2015/01/11/css-selectors-4/ https://grack.com/blog/2015/01/11/css-selectors-4/
[2] https://drafts.csswg.org/selectors-4/#profiles https://drafts.csswg.org/selectors-4/#profiles
- combatentropy 10y agoIt's a little disappointing if the :has selector never makes it into stylesheets, just JavaScript's querySelector. Then again I'm thankful for what we already have. For example, even the old :hover selector seems to me like it would have been slow, but it's not. Others like :checked, :disabled, and :target further eliminate some JavaScript. HTML 5 eliminates more, like autofocus, datepickers, and most form checking (I think? I haven't used it much.) The :has selector would have wiped out all but about 2% of my JavaScript needs. Don't get me wrong. I don't mind JavaScript as much as other people. In fact, I kind of like it. But given the choice between declarative (CSS) and procedural (JavaScript) it's generally shorter to use declarative.