Closed
Description
If there is an element with a class={someVariable}
attribute in the markup, :global(body) .className
child selectors get suffixed, and therefore don't apply to child components.
For example, if you have a parent component that applies a "theme" class to its top-level element, and has child selectors to style matching elements within all its child components depending on the theme, it doesn't work if the theme class is a variable (but does if it's hard-coded as e.g. <div class="purple">
.
(The variable class is what's relevant - any element with a non-hard-coded class name in the parent component will break it.)
REPL:
- reproduction: https://svelte.dev/repl/0cf466aa625c42ed9dc845d0b46d1905?version=3.17.3
- fixed (by removing variable class name): https://svelte.dev/repl/2f88829ff20846a79e8c395f8ecef741?version=3.17.3