Skip to content

Wrong unused CSS selector handling when multiple selectors used for one ruleset #14426

@laborci

Description

@laborci

Describe the bug

Svelte removes all selectors when there is an unused selector in the selectors list. To be more specific, it removes all selectors when there are more unused selectors then used or something like that. It behaves very wierdly.

Reproduction

Repl

<h1>This should be red, underlined, uppercase, and with green background</h1>
<h4>This should be uppercase and with green background</h4>


<style>
    h1, h2, h3 {
        color: red;
    }
    h1, h2 {
        text-decoration: underline;
    }

    h1, h2, h3, h4 {
        text-transform: uppercase;
    }

    h1, h2, h3, h4, h5, h6 {
        background-color: green;
    }
</style>

Logs

No response

System Info

System:
    OS: macOS 15.2
    CPU: (8) arm64 Apple M3
    Memory: 96.95 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.19.1 - ~/.nvm/versions/node/v18.19.1/bin/node
    npm: 10.2.4 - ~/.nvm/versions/node/v18.19.1/bin/npm
    pnpm: 8.15.5 - /opt/homebrew/bin/pnpm
    bun: 1.1.36 - /opt/homebrew/bin/bun
  Browsers:
    Brave Browser: 130.1.71.118
    Chrome: 131.0.6778.86
    Edge: 131.0.2903.63
    Safari: 18.2
  npmPackages:
    svelte: ^5.2.7 => 5.2.7

Severity

annoyance

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions