Skip to content

fix: render :has() hover preview as nested HTML - #583

Open
Adithya kumar Reddy Gopavaram (ADITHYAKUMARREDDY) wants to merge 1 commit into
microsoft:mainfrom
ADITHYAKUMARREDDY:fix-has-selector-hover
Open

Adithya kumar Reddy Gopavaram (ADITHYAKUMARREDDY) wants to merge 1 commit into
microsoft:mainfrom
ADITHYAKUMARREDDY:fix-has-selector-hover

Conversation

@ADITHYAKUMARREDDY

Fixes

microsoft/vscode#191897

Problem

Hovering a selector like article:has(.alert) showed a misleading HTML preview:

<article :has>

:has() is a relative pseudo-class, not an HTML attribute.

Fix

Render the first relative selector argument of :has() as nested markup under the subject element:

  • article:has(.alert) → descendant preview with …
  • article:has(> .alert) → direct child preview
  • selector lists use the first entry
  • sibling combinators (+, ~) keep the previous attribute form (need parent context)

:not(), :is(), and :where() are unchanged.

Test

  • Updated existing :has() marked-string expectations
  • Added coverage for the vscode#191897 example, child combinator, selector list, and sibling fallback
  • npm test — 425 passing

Show the relative selector argument of :has() as descendant/child
markup instead of a bogus attribute like `<article :has>`.

Fixes microsoft/vscode#191897
@ADITHYAKUMARREDDY

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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.

1 participant