W3C home > Mailing lists > Public > public-css-archive@w3.org > November 2018

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

From: Emilio Cobos Álvarez via GitHub <sysbot+gh@w3.org>
Date: Mon, 26 Nov 2018 09:43:03 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-441576913-1543225382-sysbot+gh@w3.org>
> 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

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:39 UTC