Skip to content

Commit 4c9ade6

Browse files
philipp-spiessadamwathan
authored andcommitted
Fix svelte class: shorthand to work with newlines and tabs
1 parent 35bc28b commit 4c9ade6

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

crates/oxide/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ fn read_changed_content(c: ChangedContent) -> Option<Vec<u8>> {
447447
};
448448

449449
match extension {
450-
Some("svelte") => Some(content.replace(" class:", " ")),
450+
Some("svelte") => Some(content.replace(" class:", " ").replace("\tclass:", " ")),
451451
_ => Some(content),
452452
}
453453
}

crates/oxide/tests/scanner.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,12 +325,22 @@ mod scanner {
325325
("foo.html", "lg:font-bold"),
326326
// A svelte file with `class:foo="bar"` syntax
327327
("index.svelte", "<div class:px-4='condition'></div>"),
328+
("index2.svelte", "<div\n\tclass:px-5='condition'></div>"),
329+
("index3.svelte", "<div\n class:px-6='condition'></div>"),
328330
])
329331
.1;
330332

331333
assert_eq!(
332334
candidates,
333-
vec!["condition", "div", "font-bold", "md:flex", "px-4"]
335+
vec![
336+
"condition",
337+
"div",
338+
"font-bold",
339+
"md:flex",
340+
"px-4",
341+
"px-5",
342+
"px-6"
343+
]
334344
);
335345
}
336346

0 commit comments

Comments
 (0)