Skip to content

Scoped styles behave differently in Astro 6 #15907

@jmbockhorst

Description

@jmbockhorst

Astro Info

Astro                    v6.0.4
Vite                     v7.3.1
Node                     v22.22.0
System                   MacOS (arm64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Scoped styles behave differently in Astro 6, which is causing our codebase to break. This seems like a regression, unless it was an intentional breaking change. Seems related to #14032.

When I have an Astro component like this:

<style>
    nav {
      a {
        color: deeppink;
      }
    }
</style>

<nav>
    <Link />
</nav>

and Link.astro is:

<a href="#">test</a>

What's the expected result?

Astro 5 produced this output:

<nav data-astro-cid-hujapecf> 
    <a href="#">test</a> 
</nav>
nav[data-astro-cid-hujapecf] {
    a { 
        color: deeppink; 
    }
}

Astro 6 produces this output:

<nav data-astro-cid-hujapecf> 
    <a href="#">test</a> 
</nav>
nav[data-astro-cid-hujapecf] {
    a[data-astro-cid-hujapecf] { 
        color:deeppink 
    }
}

Link to Minimal Reproducible Example

https://stackblitz.com/~/github.com/jmbockhorst/astro-scoping-bug

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

Labels

- P4: importantViolate documented behavior or significantly impacts performance (priority)pkg: astroRelated to the core `astro` package (scope)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions