Repository navigation
Use nesting instead of scoped css - #3939
Conversation
|
I've checked and it looks good now in both the old and the new version of firefox. This still makes the html representations render correctly in MKDocs, which was the original issue that triggered the changes to the stylesheets. |
SimonHeybrock
left a comment
There was a problem hiding this comment.
I checked the desugaring and it's equivalent: inside @scope the implied :scope counts as a pseudo-class (0,1,0), so specificity is unchanged, :scope.sc-wrap → &.sc-wrap is the right translation, and hoisting the .dg-root declarations out of :scope {} is correct. The regex minifier in resources.py is selector-agnostic, so nothing breaks there. No objection to merging.
But: why any 2023-era feature at all? The wrapper does no cascade work here -- the !important declarations do. Written flat, .sc-root .foo { ... } is exactly equivalent and parses in every browser ever shipped. The floors we're choosing between:
| Chrome | Firefox | Safari | |
|---|---|---|---|
@scope |
118 | 128 | 17.4 |
| nesting, relaxed syntax | 120 | 117 | 17.2 |
| flat descendant selectors | all | all | all |
Relaxed syntax is required because many nested selectors start with a type (ul.sc-sections, pre.sc-var-data, input.dg-header-in, dl.sc-attrs). In Chrome 112-119 and Safari 16.5-17.1 those rules are dropped while the class-only ones survive -- partially styled, which is the exact broken-layout mode this stylesheet exists to prevent. Firefox ESR 115, still common on institutional Linux, supports neither feature.
So this trades one narrow broken window for another. Flat selectors close the category for good, at the cost of repeating an 8-character prefix in a file we touch twice a year. Since the whole motivation is "someone's browser is too old", I'd take that trade.
If you'd rather keep the nesting, two small asks:
- A comment in both files noting the prefix-by-nesting is deliberate and why
@scopeis unusable, otherwise this gets modernized back in a year. - The tested Firefox version in the PR description -- "old and new version of firefox" doesn't pin down what's actually covered.
|
Opened #3941 with the prefix-selector variant so it can be compared side by side -- whichever you prefer, the other should be closed. |
|
I don't think it is necessary to go through another round of changes and testing to make sure we support browsers from before 2023. That just does not seem meaningful. If you prefer that version feel free to implement it and merge what you prefer. |
|
I changed my opinion. The change is simple and the peace of mind knowing the docs are not broken anywhere is worth it 👍 |
Fixes the browser incompatibility issue that Celine discovered today.