fix: merge multiple class attributes into single attribute

- codegen.zig: collect class values and output as single merged attribute
- template.zig: respect quoted flag to prevent data lookup for static class values
- Added tests for multiple class merging scenarios
This commit is contained in:
2026-01-29 22:04:59 +05:30
parent aa77a31809
commit 416ddf5b33
5 changed files with 62 additions and 13 deletions

View File

@@ -202,6 +202,18 @@ test "Implicit div with ID" {
try expectOutput("#content", .{}, "<div id=\"content\"></div>");
}
test "Multiple classes merged into single attribute" {
try expectOutput("div.foo.bar.baz", .{}, "<div class=\"foo bar baz\"></div>");
}
test "Multiple classes with text" {
try expectOutput(".a.b hello", .{}, "<div class=\"a b\">hello</div>");
}
test "Class attribute merged with shorthand classes" {
try expectOutput("div(class=\"foo\").bar.baz", .{}, "<div class=\"foo bar baz\"></div>");
}
// ─────────────────────────────────────────────────────────────────────────────
// Test Case 10: &attributes spread operator
// TODO: &attributes spread with JS object literal not yet implemented