Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class directive breaks with token "/" for TailwindCSS width classes #4072

Closed
jerriclynsjohn opened this issue Dec 9, 2019 · 12 comments · Fixed by #14714
Closed

Class directive breaks with token "/" for TailwindCSS width classes #4072

jerriclynsjohn opened this issue Dec 9, 2019 · 12 comments · Fixed by #14714
Assignees
Labels
css Stuff related to Svelte's built-in CSS handling
Milestone

Comments

@jerriclynsjohn
Copy link

Describe the bug
When using specific classes like "w-1/2", which is standard tailwind class, the svelte compiler throws an error "Expected >svelte(unexpected-token)"

I'm pretty sure it is because the compiler assumes token ">" after the token in question "/".

To Reproduce
Write any code with a class directive class:sm:w-1/2={!contact} in a Svelte+Tailwind project.

Expected behavior
Compiler should not assume that the closing ">" token to succeed token "/" in a string after the class directive.

@jerriclynsjohn
Copy link
Author

This bug is not reproducible now and I'm closing the issue.

@simonbernard2
Copy link

I'm also having this bug.

@benwoodward
Copy link

benwoodward commented Mar 2, 2022

I'm experiencing this too, in 3.44.2, what version are you on?

image

Also finding that Svelte doesn't recognise border-gray-400 and border-gray-400/50 as distinct attributes:

image

EDIT: Also happening if I remove the shorthand syntax:

image

EDIT: Also happening if the class doesn't clash at all:

image

I should add that I'm using windicss v3.2.1 and vite-plugin-windicss v1.5.4.

EDIT: Upgrading to svelte 3.46.4, windicss 3.5.0 and vite-plugin-windicss v1.8.1 did not fix this issue for me.

@geoffrich
Copy link
Member

Reopening since this still seems to be an issue - can someone provide a REPL showing the issue?

@git-no
Copy link

git-no commented Mar 15, 2022

@geoffrich

Reopening since this still seems to be an issue - can someone provide a REPL showing the issue?

Here is example repositoryI created for you with the issue in index.svelte git repo

@benwoodward
Copy link

@git-no thanks, I totally forgot to do this.

@git-no
Copy link

git-no commented Mar 16, 2022

I have also this issue, Class directive breaks with token "/" for TailwindCSS

@filpgc
Copy link

filpgc commented Sep 29, 2023

any update on this?

@git-no
Copy link

git-no commented Sep 29, 2023

I remove my demo repository because it was not used for 1 1/2 years.

To remind, this does not work: class:bg-red-600/10={hasError}

@Rich-Harris
Copy link
Member

Confirmed still broken in Svelte 5. Related: #7170

@dummdidumm
Copy link
Member

See #7170 (comment) for a proposal

@dummdidumm dummdidumm added the css Stuff related to Svelte's built-in CSS handling label Apr 6, 2024
@dummdidumm dummdidumm modified the milestones: 5.0, 5.x May 13, 2024
@Serator
Copy link

Serator commented May 16, 2024

Reproduction

<div class:bg-white/5={true}></div> causes an error: Expected token >.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css Stuff related to Svelte's built-in CSS handling
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants