[csswg-drafts] [selectors-4] Consider disallowing :has() outside the rightmost compound (#6845)

anttijk has just created a new issue for https://github.com/w3c/csswg-drafts:

== [selectors-4] Consider disallowing :has() outside the rightmost compound ==
Consider a rule like

`:has(.foo) div { ... }`

With this, style of every div in the document becomes dependent on the class lists of every element in the document. Specific cases can be optimized but in general case this means the engine has to do expensive full-document invalidation (or style recalc) on every document mutation (or pseudo class change) that may affect :has results. This is a potential performance footgun.

The invalidation scope can be drastically reduced by limiting :has() to rightmost compound only. This means that only ancestors/sibling chains needs to be considered for invalidation on :has()-affecting mutation. This is analogous to how only descendants/siblings need to be considered for regular selectors.

Sensible use cases for :has() are likely in the rightmost compound anyway so it seems better to not have this footgun around.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6845 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 30 November 2021 11:51:16 UTC