-
Notifications
You must be signed in to change notification settings - Fork 647
perf(BaseStyles): Remove expensive :has([data-color-mode]) selectors #7325
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
base: main
Are you sure you want to change the base?
Conversation
Remove :has([data-color-mode]) selectors that scanned the entire DOM on every style recalculation. Input color-scheme is already handled by global selectors. Part of #7312
🦋 Changeset detectedLatest commit: d81e6ef The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Or, apply the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR removes performance-impacting CSS selectors from BaseStyles that were causing expensive DOM traversals during style recalculation. The removed :has([data-color-mode]) selectors scanned the entire DOM tree unnecessarily, as the input color-scheme functionality is already handled by existing global selectors elsewhere in the codebase.
Key Changes:
- Removed redundant
:has([data-color-mode='light'])and:has([data-color-mode='dark'])selectors - Added explanatory comment documenting why the selectors were removed and where the functionality is handled
- Added changeset documenting the performance improvement
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/react/src/BaseStyles.module.css | Removed expensive :has() selectors and replaced with explanatory comment |
| .changeset/perf-basestyles-has-selector.md | Added changeset documenting the performance optimization |
|
👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/9374 |
Summary
Remove expensive
:has([data-color-mode])selectors that scanned the entire DOM on every style recalculation.Changes
Removed redundant CSS rules that used
:has([data-color-mode='light'])and:has([data-color-mode='dark'])selectors. Input color-scheme is already handled by global selectors in the codebase.Expected INP Impact
Why this matters
These were the most expensive selectors in the entire codebase:
:has([data-color-mode])on the root element forces a full DOM traversalThis single change likely has the highest INP impact of all the optimizations.
Part of the INP performance optimization effort. See #7312 for full context.