Skip to content

Add best practice: avoid body:has() workbench-wide selectors#325400

Merged
benvillalobos merged 1 commit into
mainfrom
bv/css-has-perf-guideline
Jul 11, 2026
Merged

Add best practice: avoid body:has() workbench-wide selectors#325400
benvillalobos merged 1 commit into
mainfrom
bv/css-has-perf-guideline

Conversation

@benvillalobos

Copy link
Copy Markdown
Member

Follow-up to #324986, which fixed a workbench UI perf regression caused by a body:has(.automation-dialog) selector. :has() anchored on body forces 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

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.
Copilot AI review requested due to automatic review settings July 11, 2026 00:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
benvillalobos marked this pull request as ready for review July 11, 2026 01:11
@benvillalobos
benvillalobos merged commit 2b8fc29 into main Jul 11, 2026
30 checks passed
@benvillalobos
benvillalobos deleted the bv/css-has-perf-guideline branch July 11, 2026 01:39
@vs-code-engineering vs-code-engineering Bot added this to the 1.129.0 milestone Jul 11, 2026
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.

4 participants