Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pseudo class and pseudo element only selectors break scoped styles #706

Closed
1 task
kagankan opened this issue Jan 7, 2023 · 5 comments
Closed
1 task
Labels
- P3: minor bug An edge case that only affects very specific usage (priority)

Comments

@kagankan
Copy link

kagankan commented Jan 7, 2023

What version of astro are you using?

1.9.0

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Windows 11

Describe the Bug

Current behavior

<a href=""></a>

<style>
  :any-link::after {
    content: "link";
  }
</style>

The style is converted to the CSS below:

:any-link:after:where(.astro-RJEN7MQD){content:"link"}

The style is not applied to the a element.

Expected behavior

:any-link:where(.astro-RJEN7MQD):after{content:"link"}
/* or */
:where(.astro-RJEN7MQD):any-link:after{content:"link"}

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-bqgpy9?file=src/pages/index.astro

Participation

  • I am willing to submit a pull request for this issue.
@bluwy bluwy transferred this issue from withastro/astro Jan 16, 2023
@bluwy
Copy link
Member

bluwy commented Jan 16, 2023

For reference, Svelte converts to something like :where(.astro-RJEN7MQD):any-link:after{content:"link"}, which I also think is the correct behaviour.

@bluwy bluwy added the - P3: minor bug An edge case that only affects very specific usage (priority) label Jan 16, 2023
@jasikpark
Copy link
Contributor

the problem here is that the scoped style class is selectively applied to elements depending on whether astro believes they will be styled, right? so if the <a> element got the class, it'd be fine

@bluwy
Copy link
Member

bluwy commented Jan 16, 2023

The <a> element does get the class, but the generated scoped css doesn't reflect that:

:any-link::after:where(.astro-RJEN7MQD){content:"link"}

The scoped class is targetting the ::after pseudoselector instead of :any-link. And because there's no astro-RJEN7MQD attached to the pseudoselector (it can't have classes too), the style isn't applied properly.

@JakobJK
Copy link

JakobJK commented Jul 29, 2023

I believe I am running into this issue as well. I cannot style images in markdown using the pseudo-classes.

@bluwy
Copy link
Member

bluwy commented Nov 27, 2023

Closing this in favour of #794. That issue is a little newer, but it has more examples that should help us implement the proper tests for it.

@bluwy bluwy closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

No branches or pull requests

4 participants