Re: [csswg-drafts] More intuitive names for selector performance profiles

@SelenIT Of course lots of people would love `:has()` in the live profile. But I disagree that having it only in the non-live profile is useless, as proven by the widely-used selector-based JS libraries like jQuery.

You mention other selectors which depend on nested or following elements. An implementator would know better than me, but I'm not sure these are that expensive. For `:focus-within` you only need to set flags to the ancestor elements when focus changes, then `:focus-within` matches if the flag is set on that element (e.g. see [Firefox's implementation](https://bugzilla.mozilla.org/page.cgi?id=splinter.html&bug=1176997&attachment=8789682)). `:empty` should also be easy, you only need to know if the element has some child node, and in most cases the engine will know this. Browsers usually render content in chunks, so presumably the problem is when the current chunk ends just after the start tag of the element, in this case the next chunk might add a child, but this only requires recalculating the styles of a single element, there is no subtree to be updated. `:nth-last-*` seems more complex, I don't know what browsers do but I guess they use some trick to avoid big performance impacts in most cases.

What I mean is that it can be reasonable to add some specific selectors to the live profile even if they depend on nested or following elements, but `:has()` covers the general case and thus is so hard to optimize. It might eventually be possible to add `:has()` to the live profile (maybe imposing some restrictions to its argument?), but meanwhile I think it's good that `:has()` in JS is not held back.

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

Received on Monday, 7 August 2017 10:35:03 UTC