Add best practice: avoid body:has() workbench-wide selectors#325400
Merged
Conversation
A body:has() selector forces the style engine to re-evaluate against the whole document on nearly every DOM mutation, degrading workbench interaction perf even in builds where the feature is disabled. Document the class-on-container alternative under the Styling best practices.
Contributor
There was a problem hiding this comment.
Pull request overview
Documents a CSS performance safeguard to prevent workbench-wide selector invalidation.
Changes:
- Prohibits globally anchored
:has()selectors. - Recommends scoped container classes with disposable cleanup.
Show a summary per file
| File | Description |
|---|---|
.github/instructions/best-practices.instructions.md |
Adds the styling best practice and replacement pattern. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Medium
benvillalobos
marked this pull request as ready for review
July 11, 2026 01:11
DonJayamanne
approved these changes
Jul 11, 2026
roblourens
approved these changes
Jul 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #324986, which fixed a workbench UI perf regression caused by a
body:has(.automation-dialog)selector.:has()anchored onbodyforces the style engine to re-evaluate against the whole document on nearly every DOM mutation, so the cost is workbench-wide (and ships even where the feature is disabled).Adds one bullet under the Styling best practices documenting the footgun and the class-on-container alternative, so we do not reintroduce it.
Refs #324986