Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/perf-basestyles-has-selector.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@primer/react': patch
---

perf(BaseStyles): Remove expensive :has([data-color-mode]) selectors

Remove `:has([data-color-mode])` selectors that scanned the entire DOM on every style recalculation.
Input color-scheme is already handled by global selectors in the codebase.
19 changes: 6 additions & 13 deletions packages/react/src/BaseStyles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,12 @@ details-dialog:focus:not(:focus-visible):not(:global(.focus-visible)) {
/* stylelint-disable-next-line primer/colors */
color: var(--BaseStyles-fgColor, var(--fgColor-default));

/* Global styles for light mode */
&:has([data-color-mode='light']) {
input & {
color-scheme: light;
}
}

/* Global styles for dark mode */
&:has([data-color-mode='dark']) {
input & {
color-scheme: dark;
}
}
/*
* PERFORMANCE: Removed :has([data-color-mode]) selectors that scanned entire DOM.
* Input color-scheme is already handled by global selectors above:
* [data-color-mode='light'] input { color-scheme: light; }
* [data-color-mode='dark'] input { color-scheme: dark; }
*/

/* Low-specificity default link styling */
:where(a:not([class*='prc-']):not([class*='PRC-']):not([class*='Primer_Brand__'])) {
Expand Down
Loading