language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

svelte-check error with nth-last-child selector

Open theodorejb opened this issue 2 years ago • 1 comments

Describe the bug

In my Svelte component I have a style tag with the following rule:

tr:nth-last-child(1 of :not(.d-sm-none)) {
    border-bottom: 0;
}

The CSS works fine, but when I run svelte-check, it outputs the following errors:

Error: at-rule or selector expected (css)
        border-bottom: 0;
    }
</style>


c:\Users\Theodore\my-project\src\lib\MyComponent.svelte:75:44
Error: { expected (css)
<style>
    tr:nth-last-child(1 of :not(.d-sm-none)) {
        border-bottom: 0;


c:\Users\Theodore\my-project\src\lib\MyComponent.svelte:75:25
Error: ) expected (css)
<style>
    tr:nth-last-child(1 of :not(.d-sm-none)) {
        border-bottom: 0;


====================================
svelte-check found 3 errors and 0 warnings in 1 file

Reproduction

See above description.

Expected behaviour

Svelte-check should not output a syntax error for this valid CSS.

System Info

  • OS: Windows
  • IDE: VSCode

Which package is the issue about?

svelte-check

Additional Information, eg. Screenshots

Strangely, there is no error with the following CSS:

tr:nth-last-child(odd of :not(.d-sm-none)) {
    border-bottom: 0;
}

So svelte-check seems to specifically fail to parse to the CSS when the first argument to nth-last-child is something other than odd or even.

theodorejb avatar May 23 '23 23:05 theodorejb

This has only been implemented in Chrome and Firefox very recently. See the issue on the VSCode repo https://github.com/microsoft/vscode/issues/181560. We use the same underlying library that is maintained by the VSCode team.

jasonlyu123 avatar May 24 '23 00:05 jasonlyu123

Should work now since we bumped the css language service dep

dummdidumm avatar Jul 31 '24 12:07 dummdidumm