Skip to content

Commit ed3cecd

Browse files
Support Leptos class: attributes (#18093)
<!-- 👋 Hey, thanks for your interest in contributing to Tailwind! **Please ask first before starting work on any significant new features.** It's never a fun experience to have your pull request declined after investing a lot of time and effort into a new feature. To avoid this from happening, we request that contributors create a discussion to first discuss any significant new features. For more info, check out the contributing guide: https://github.com/tailwindcss/tailwindcss/blob/main/.github/CONTRIBUTING.md --> Fixes #18092 ## Summary Using the Svelte preprocessor for Rust files we can support Leptos `class:` attributes syntax. ## Test plan ``` pnpm t ``` --------- Co-authored-by: Robin Malfait <[email protected]>
1 parent 24ed64e commit ed3cecd

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Upgrade: Do not migrate declarations that look like candidates in `<style>` blocks ([#18057](https://github.com/tailwindlabs/tailwindcss/pull/18057), [18068](https://github.com/tailwindlabs/tailwindcss/pull/18068))
1313
- Upgrade: Improve `pnpm` workspaces support ([#18065](https://github.com/tailwindlabs/tailwindcss/pull/18065))
14+
- Support Leptos `class:` attributes when extracting classes ([#18093](https://github.com/tailwindlabs/tailwindcss/pull/18093))
1415

1516
## [4.1.7] - 2025-05-15
1617

crates/oxide/src/extractor/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,23 @@ mod tests {
10541054
);
10551055
}
10561056

1057+
// See: https://github.com/tailwindlabs/tailwindcss/issues/18092
1058+
#[test]
1059+
fn test_leptos_rs_view_class_colon_syntax() {
1060+
for (input, expected) in [
1061+
(
1062+
r#"<div class:px-6=true>"#,
1063+
vec!["class", "px-6"],
1064+
),
1065+
(
1066+
r#"view! { <div class:px-6=true> }"#,
1067+
vec!["class", "px-6", "view!"],
1068+
),
1069+
] {
1070+
assert_extract_sorted_candidates(&pre_process_input(input, "svelte"), expected);
1071+
}
1072+
}
1073+
10571074
#[test]
10581075
fn test_extract_css_variables() {
10591076
for (input, expected) in [

crates/oxide/src/scanner/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ pub fn pre_process_input(content: &[u8], extension: &str) -> Vec<u8> {
488488
"pug" => Pug.process(content),
489489
"rb" | "erb" => Ruby.process(content),
490490
"slim" => Slim.process(content),
491-
"svelte" => Svelte.process(content),
491+
"svelte" | "rs" => Svelte.process(content),
492492
"vue" => Vue.process(content),
493493
_ => content.to_vec(),
494494
}

0 commit comments

Comments
 (0)