Skip to content

Compound global selector check is too restrictive #9207

@TGlide

Description

@TGlide

Describe the bug

I was trying to do the following:

.anim-checkbox:global([data-state='checked']) {
	background-color: red;
}

But received an error: :global(...) not at the start of a selector sequence should not contain type or universal selectors(css-invalid-global-selector-position)

Digging into Svelte's issues, I found that this check comes from issue #6272. I fear the fix implemented is too restrictive, as I think my syntax would be perfectly valid.

For now, I have this work-around:

.anim-checkbox:global(.anim-checkbox[data-state='checked']) {
	background-color: red;
}

Reproduction

Write the following into any style tag in a .svelte file:

 .a:global([data-state]) {
  /* ... */
}

Logs

No response

System Info

System:
    OS: Linux 5.15 Ubuntu 20.04.4 LTS (Focal Fossa)
    CPU: (12) x64 11th Gen Intel(R) Core(TM) i5-11400F @ 2.60GHz
    Memory: 12.15 GB / 15.57 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 20.4.0 - ~/.nvm/versions/node/v20.4.0/bin/node
    Yarn: 1.22.15 - ~/.nvm/versions/node/v20.4.0/bin/yarn
    npm: 9.7.2 - ~/.nvm/versions/node/v20.4.0/bin/npm
    pnpm: 8.6.7 - ~/.nvm/versions/node/v20.4.0/bin/pnpm
  npmPackages:
    svelte: ^4.2.0 => 4.2.0

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    cssStuff related to Svelte's built-in CSS handling

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions