The specificity of the selector containing the `:has()` pseudo-class appears to be higher than the specificity of the selector with the same number of classes without it. Steps to reproduce: 1. Navigate to the https://codesandbox.io/s/peaceful-edison-8kcudt?file=/index.html demo 2. Check the background color of the three cards 3. Open Web Inspector 4. Inspect computed styles of the first card Expected results: The first card is light green, the next two cards are light blue. Web Inspector shows that the rule for the `.card.card--green` selector has overridden the rule for the `.card:has(.title)` selector (as having the same specificity but coming later in the code). Actual results: All three cards are light blue. Web Inspector shows that the rule for the `.card:has(.title)` selector has overridden the rule for the `.card.card--green` selector. There is a closed bug https://bugs.webkit.org/show_bug.cgi?id=235351 regarding the same topic, so it might be a regression. Both stable Safari 15.5 and Safari TP 148 display the same behavior. Chrome 103 with the "Experimental Web Platform features" flag enabled displays expected results.
:is() & :not() have the same issue.
(In reply to Tim Nguyen (:ntim) from comment #1) > :is() & :not() have the same issue. I see the :has() issue but I'm not seeing that. Please file a separate bug with a test case.
Created attachment 460675 [details] Patch
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see https://trac.webkit.org/wiki/WPTExportProcess
Committed 252140@main (7af18efe7e89): <https://commits.webkit.org/252140@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 460675 [details].
<rdar://problem/96449421>