Child elements automatically receive scoping class
#5112
Labels
- P3: minor bug
An edge case that only affects very specific usage (priority)
class
#5112
What version of
astro
are you using?1.4.7
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
npm
What operating system are you using?
Mac
Describe the Bug
Astro automatically adds a "scoping" class to all child elements whenever a parent contains a
<style>
tag.This is probably intended to open up the possibility to style children without using global styles but it potentially breaks scoping.
As an example:
in
SomeComponent
, astro will automatically add the scoping classastro-XYZ
toButton
and, asButton
is ready to receive and consume external classes, it will inherit the parent's 50px padding..host:where(.astro-4SVNLVZL)
is true because we used the same class name on both components, which defeats a bit the purpose of having scoped styles.I have prepared a quick stackblitz repro to better understand what's going on.
I did not find anything in the documentation about this so I'm not sure if this is intended but, IMO, automatically pass the scoping class as a prop seems buggy behavior. I am happy to help and open up a Pull Request if needed.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-twgta2?file=src/pages/index.astro
Participation
The text was updated successfully, but these errors were encountered: