Use attributes for checkbox rendering

This commit is contained in:
Adrià Arrufat
2026-02-18 22:48:46 +09:00
parent ce5dad722f
commit d264ff2801

View File

@@ -249,14 +249,15 @@ fn renderElement(el: *Element, state: *State, writer: *std.Io.Writer, page: *Pag
return; return;
}, },
.input => { .input => {
const input = el.as(Element.Html.Input); if (el.getAttributeSafe(comptime .wrap("type"))) |type_attr| {
if (input._input_type == .checkbox) { if (std.ascii.eqlIgnoreCase(type_attr, "checkbox")) {
if (input._checked) { if (el.getAttributeSafe(comptime .wrap("checked"))) |_| {
try writer.writeAll("[x] "); try writer.writeAll("[x] ");
} else { } else {
try writer.writeAll("[ ] "); try writer.writeAll("[ ] ");
}
state.last_char_was_newline = false;
} }
state.last_char_was_newline = false;
} }
return; return;
}, },