Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid :has selector in CSS. #395

Merged
merged 1 commit into from
Mar 6, 2024
Merged

Conversation

mstange
Copy link
Contributor

@mstange mstange commented Mar 5, 2024

Fixes #394.

This changes how section visibility is controlled. All sections are still display:none by default.
Rather than becoming display:block when they match :target, they now become display:block if their ID matches the value of the root element's data-visible-section attribute - we hardcode the four section names "home", "running", "summary" and "details".

This lets us default to the home section just by setting <html data-visible-section="home"> in index.html, and we can avoid the :has selector.

Now Speedometer can run in older browsers which don't support :has.

This changes how section visibility is controlled.
All sections are still `display:none` by default.
Rather than becoming `display:block` when they match `:target`,
they now become `display:block` if their ID matches the value
of the root element's `data-visible-section` attribute - we hardcode
the four section names "home", "running", "summary" and "details".

This lets us default to the home section just by setting
`<html data-visible-section="home">` in index.html, and we
can avoid the `:has` selector.

Now Speedometer can run in older browsers which don't support `:has`.
@mstange mstange force-pushed the no-target-pseudoclass branch from 9b4290e to 5a6c9a8 Compare March 5, 2024 19:09
Copy link
Contributor

@julienw julienw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. IMO It's also simple enough to land in v3.0 but of course please test it in your respective browsers. (I tested myself in firefox nightly, stable and esr, as well as chrome dev and stable)

At this point the hash is only useful so that we can press back/forward buttons between the summary and details views. Is it worth the extra code? (Question for v3.1)

@rniwa rniwa merged commit 3d2a28e into WebKit:main Mar 6, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

:has selector breaks speedometer in older browsers
5 participants