Bug 270900 - [css-cascade] Proximity for implicit scopes seems to be ignored for rules with zero specificity
Summary: [css-cascade] Proximity for implicit scopes seems to be ignored for rules wit...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: Safari 17
Hardware: All All
: P2 Normal
Assignee: Matthieu Dubet
URL:
Keywords: HasReduction, InRadar
Depends on:
Blocks:
 
Reported: 2024-03-12 23:38 PDT by Nathan Knowler
Modified: 2024-03-19 13:52 PDT (History)
6 users (show)

See Also:


Attachments
Reduced test case for implicit scope’s proximity being override by explicit scope when selectors have zero specificity. (2.71 KB, text/html)
2024-03-12 23:38 PDT, Nathan Knowler
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Knowler 2024-03-12 23:38:54 PDT
Created attachment 470334 [details]
Reduced test case for implicit scope’s proximity being override by explicit scope when selectors have zero specificity.

When an implicit `@scope` (i.e. a scope within an embedded style without an explicit scope root) is used and it contains a rule that has a sum of zero specificity (0,0,0) like the universal selector (i.e. `*`) or a selector wrapped with the `:where()` pseudo-class function, it seems like less proximate scopes with the same specificity can override the local scope. The only workaround is to bump the specificity of the selector used in the local scope.

From what I’ve observed:

- Other properties for the same selector with zero specificity inside the implicit scope where there is no conflict apply fine.
- Order of appearance does not seem to cause any difference (e.g. ordering the less proximate explicit scope rule before or after the implicit one), so I assume this is a problem with how scope proximity is being determined for this situation.
Comment 1 Radar WebKit Bug Importer 2024-03-14 14:50:54 PDT
<rdar://problem/124640124>
Comment 2 Matthieu Dubet 2024-03-14 16:58:55 PDT
Pull request: https://github.com/WebKit/WebKit/pull/25918
Comment 3 EWS 2024-03-19 07:43:17 PDT
Committed 276345@main (7b99ea4ee244): <https://commits.webkit.org/276345@main>

Reviewed commits have been landed. Closing PR #25918 and removing active labels.