Skip to content

svelte5 and root element "&" nesting selector #13838

@tanangular

Description

@tanangular

Describe the bug

I know svelte5 is compatible with CSS nesting, but it seems the compiler is giving me an error when using "&" as for the root element.
"Nesting selectors can only be used inside a rule or as the first selector inside a lone :global(...) (css_nesting_selector_invalid_placement)"
ref: https://css-tip.com/root-selector/
Screenshot 2567-10-24 at 00 52 15
Screenshot 2567-10-24 at 00 54 10

Reproduction

https://svelte.dev/playground/0301a48be01b490ea4d1bdeacd9c17a7?version=5.0.5

Logs

No response

System Info

System:
    OS: macOS 15.0.1
    CPU: (12) arm64 Apple M2 Max
    Memory: 21.97 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.9.0 - ~/.nvm/versions/node/v22.9.0/bin/node
    npm: 10.8.3 - ~/.nvm/versions/node/v22.9.0/bin/npm
    pnpm: 9.12.1 - ~/Library/pnpm/pnpm
    bun: 1.1.30 - ~/.bun/bin/bun
  Browsers:
    Edge: 130.0.2849.52
    Safari: 18.0.1

Severity

annoyance

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