Skip to content

fix: avoid double-scoping nested CSS pseudo selectors#1145

Merged
Princesseuh merged 2 commits intowithastro:mainfrom
tgfjt:fix/1128-css-double-scoping
Feb 17, 2026
Merged

fix: avoid double-scoping nested CSS pseudo selectors#1145
Princesseuh merged 2 commits intowithastro:mainfrom
tgfjt:fix/1128-css-double-scoping

Conversation

@tgfjt
Copy link
Contributor

@tgfjt tgfjt commented Feb 16, 2026

Changes

Fixes #1128 — regression from #1100.

The pseudo-only scoping logic didn't check !scoped, so &:last-of-type / &::before inside :global() got double-scoped. One-line fix: add !scoped guard, consistent with all other scoping branches.

Testing

Added 6 test cases, updated 1 existing expectation. All TestScopeStyle pass.

Docs

Bug fix only.

@changeset-bot
Copy link

changeset-bot bot commented Feb 16, 2026

🦋 Changeset detected

Latest commit: 59ca635

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/compiler Patch

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

…eudo selectors

close withastro#1128

The pseudo-only scoping logic added in withastro#1100 did not check whether the selector was already scoped via a nesting selector (&).
@tgfjt tgfjt force-pushed the fix/1128-css-double-scoping branch from bcd7961 to 836d169 Compare February 16, 2026 11:45
@tgfjt tgfjt changed the title fix: avoid double-scoping CSS when nesting selector is used with pseudo selectors fix: avoid double-scoping nested CSS pseudo selectors Feb 16, 2026
Copy link
Member

@Princesseuh Princesseuh left a comment

Choose a reason for hiding this comment

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

Tough! Thank you for this fix

@Princesseuh Princesseuh merged commit 755f046 into withastro:main Feb 17, 2026
5 checks passed
@tgfjt tgfjt deleted the fix/1128-css-double-scoping branch February 18, 2026 03:37
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.

🐛 BUG: [REGRESSION] Scoped CSS wrongly generated since astro@5.15.6

2 participants

Comments