-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Parse candidates in .svelte
files with class:abc="condition"
syntax
#13274
Conversation
In svelte there is a convention where you can use `<div class:px-4="condition" />` which means that we extract `class:px-4` as a utility where `class` is a variant. This is obviously incorrect, to solve this we can ignore the `class:` part before parsing the whole file. This is also what we do in v3. Ideally we have completely separate parsers for various programming languages (based on file type) and fallback to the generic one we have now. Implementing that, is a much bigger scope.
There is some funky stuff happening when running `cargo test` where it sees contents from another test. Maybe a bug in the tmpdir crate. I don't see this problem locally when running `cargo nextest run`, but when using the native `cargo test` command it fails.
CHANGELOG.md
Outdated
@@ -108,3 +109,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
- Move the CLI into a separate `@tailwindcss/cli` package ([#13095](https://github.com/tailwindlabs/tailwindcss/pull/13095)) | |||
|
|||
## [4.0.0-alpha.1] - 2024-03-06 | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is causing linting to fail. We probably should have something here though. Maybe line - Initial release
or something?
Co-authored-by: Jordan Pittman <jordan@cryptica.me>
@@ -297,9 +297,14 @@ mod auto_content { | |||
("foo.jpg", Some("xl:font-bold")), | |||
// A file that is ignored | |||
("foo.html", Some("lg:font-bold")), | |||
// A svelte file with `class:foo="bar"` syntax | |||
("index.svelte", Some("<div class:px-4='condition'></div>")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Svelte, expression would be in squiggly brackets and not quotes
<div class:px-4={condition}>
RobinMalfait I think this still isn't working in |
This PR introduces backwards compatibility for the
class:
syntax in Svelte files.In Svelte there is a convention where you can use
<div class:px-4="condition" />
which allows you to apply thepx-4
class conditionally based on a condition. This also means that we extractclass:px-4
as a utility whereclass
is a variant andpx-4
is the utility.This is obviously incorrect, to solve this we can ignore the
class:
part before parsing the whole file.This is also what we do in v3.
In a perfect world, we have more specific parsers depending on the file type before using the generic parser we use now. But that's a bigger project on its own way beyond the scope of this PR.
Fixes: #13263