RESOLVED FIXED 242328
Wrong specificity of :has() pseudo-classes
https://bugs.webkit.org/show_bug.cgi?id=242328
Summary Wrong specificity of :has() pseudo-classes
Ilya Streltsyn
Reported 2022-07-04 19:24:59 PDT
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.
Attachments
Patch (3.85 KB, patch)
2022-07-05 01:55 PDT, Antti Koivisto
no flags
Tim Nguyen (:ntim)
Comment 1 2022-07-04 21:50:26 PDT Comment hidden (obsolete)
Antti Koivisto
Comment 2 2022-07-05 00:59:37 PDT
(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.
Antti Koivisto
Comment 3 2022-07-05 01:55:34 PDT
EWS Watchlist
Comment 4 2022-07-05 01:57:47 PDT
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
EWS
Comment 5 2022-07-05 10:09:30 PDT
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].
Radar WebKit Bug Importer
Comment 6 2022-07-05 10:10:14 PDT
Note You need to log in before you can comment on or make changes to this bug.