Skip to content

:global(...) .child selector is given svelte- suffix if there is a variable class name in the html #4314

Closed
@gushogg-blake

Description

@gushogg-blake

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions