Skip to content

Don't cascade styles to nested components? #583

Closed
@ethanresnick

Description

@ethanresnick

Currently, as the Svelte docs state, "scoped" styles will still cascade to nested components. Here's an example in the repl where the parent component's styles effect the paragraph styles of the nested component: https://svelte.technology/repl?version=1.20.2&gist=473c9964efa1d3b03474b14c115dc70b

Is this desirable? It arguably has some uses, but it seems to negate half the value of the scoping—i.e., styles can't leak out of a component, but styles from parent components can leak in, which seems just as problematic.

I'll note that other libraries that isolate styles (some even using similar, attribute-selector based approaches) don't allow styles to effect nested components by default. E.g., https://www.npmjs.com/package/styled-jsx, which also has an escape hatch (in the form of .rootClassName :global(...)) that can be used to recreate this cascading effect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions