Re: [csswg-drafts] [css-selectors] `:has()` and performance (#3345)

> That’s from JavaScript. I mean the initial parsing, which ends up being fast‑ish since once you encounter c, you can send an event back to b, which would be marked as potentially matching a :has(…) selector and be updated as such.

That's not true either. The way style engines work is per-element. You build a list of all the rules on the page that match a certain element, for which you effectively need to do the work `element.matches` does for each selector of the page. There are optimizations of course to avoid matching every selector against every element (so in your example we'd only match it against every `b` element that has an `a` ancestor, but those wouldn't handle `:has`.

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

Received on Monday, 26 November 2018 09:43:04 UTC