Skip to content

Commit de19f9c

Browse files
Fix Angular class hand shortcut
1 parent 7a7bee7 commit de19f9c

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

crates/oxide/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ fn read_changed_content(c: ChangedContent) -> Option<Vec<u8>> {
447447
};
448448

449449
match extension {
450+
// Angular class shorthand
451+
Some("html") => Some(content.replace("[class.", "[")),
450452
Some("svelte") => Some(content.replace(" class:", " ").replace("\tclass:", " ")),
451453
_ => Some(content),
452454
}

crates/oxide/tests/scanner.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,11 @@ mod scanner {
323323
("foo.jpg", "xl:font-bold"),
324324
// A file that is ignored
325325
("foo.html", "lg:font-bold"),
326+
// An Angular file using the class shorthand syntax
327+
(
328+
"index.angular.html",
329+
"<div [class.underline]=\"bool\"></div>",
330+
),
326331
// A svelte file with `class:foo="bar"` syntax
327332
("index.svelte", "<div class:px-4='condition'></div>"),
328333
("index2.svelte", "<div\n\tclass:px-5='condition'></div>"),
@@ -333,13 +338,15 @@ mod scanner {
333338
assert_eq!(
334339
candidates,
335340
vec![
341+
"bool",
336342
"condition",
337343
"div",
338344
"font-bold",
339345
"md:flex",
340346
"px-4",
341347
"px-5",
342-
"px-6"
348+
"px-6",
349+
"underline"
343350
]
344351
);
345352
}

0 commit comments

Comments
 (0)