Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix svelte class: shorthand to work with newlines and tabs
  • Loading branch information
philipp-spiess authored and adamwathan committed Jan 28, 2025
commit 4c9ade609b26bf7d0fea06183eef828f0905fee2
2 changes: 1 addition & 1 deletion crates/oxide/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ fn read_changed_content(c: ChangedContent) -> Option<Vec<u8>> {
};

match extension {
Some("svelte") => Some(content.replace(" class:", " ")),
Some("svelte") => Some(content.replace(" class:", " ").replace("\tclass:", " ")),
_ => Some(content),
}
}
Expand Down
12 changes: 11 additions & 1 deletion crates/oxide/tests/scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,22 @@ mod scanner {
("foo.html", "lg:font-bold"),
// A svelte file with `class:foo="bar"` syntax
("index.svelte", "<div class:px-4='condition'></div>"),
("index2.svelte", "<div\n\tclass:px-5='condition'></div>"),
("index3.svelte", "<div\n class:px-6='condition'></div>"),
])
.1;

assert_eq!(
candidates,
vec!["condition", "div", "font-bold", "md:flex", "px-4"]
vec![
"condition",
"div",
"font-bold",
"md:flex",
"px-4",
"px-5",
"px-6"
]
);
}

Expand Down