Skip to content

Wrong CSS "Unused CSS selector" #14204

@erwanvivien

Description

@erwanvivien

Describe the bug

I think we should relax the CSS verification for attributes

In my code I had to add data-active={false as true} to not trigger the first CSS selector
Then I added the second CSS selector, but this one is not correctly picked up

Reproduction

<script lang="ts">
  //
</script>

<div class="floating-menu" data-active={false as true}>
  <div class="command-menu-tooltip"></div>
</div>

<style>
  /* This one is correctly picked up */
  .floating-menu[data-active='true'] > .command-menu-tooltip {
    background-color: red;
  }

  /* This one is not */
  .floating-menu[data-active='true'] {
    background-color: red;
  }
</style>

REPL

Logs

No response

System Info

System:
    OS: macOS 14.2.1
    CPU: (12) arm64 Apple M3 Pro
    Memory: 71.31 MB / 18.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.10.0 - ~/.nvm/versions/node/v22.10.0/bin/node
    npm: 10.9.0 - ~/.nvm/versions/node/v22.10.0/bin/npm
  Browsers:
    Chrome: 130.0.6723.93
    Safari: 17.2.1
  npmPackages:
    svelte: ^5.1.12 => 5.1.12

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting submitterneeds a reproduction, or clarificationcssStuff 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