mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-28 07:33:16 +00:00
refactor: simplify form extraction and remove const casts
This commit is contained in:
@@ -48,7 +48,7 @@ pub const FormField = struct {
|
||||
required: bool,
|
||||
value: ?[]const u8,
|
||||
placeholder: ?[]const u8,
|
||||
options: []const SelectOption,
|
||||
options: []SelectOption,
|
||||
|
||||
pub fn jsonStringify(self: *const FormField, jw: anytype) !void {
|
||||
try jw.beginObject();
|
||||
@@ -104,7 +104,7 @@ pub const FormInfo = struct {
|
||||
node: *Node,
|
||||
action: ?[]const u8,
|
||||
method: ?[]const u8,
|
||||
fields: []const FormField,
|
||||
fields: []FormField,
|
||||
|
||||
pub fn jsonStringify(self: *const FormInfo, jw: anytype) !void {
|
||||
try jw.beginObject();
|
||||
@@ -159,7 +159,7 @@ pub fn collectForms(
|
||||
try forms.append(arena, .{
|
||||
.node = node,
|
||||
.action = if (action_attr) |a| if (a.len > 0) a else null else null,
|
||||
.method = if (method_str.len > 0) method_str else null,
|
||||
.method = method_str,
|
||||
.fields = fields,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ fn detectForms(cmd: anytype) !void {
|
||||
for (forms_data) |*form| {
|
||||
const registered = try bc.node_registry.register(form.node);
|
||||
form.backendNodeId = registered.id;
|
||||
for (@constCast(form.fields)) |*field| {
|
||||
for (form.fields) |*field| {
|
||||
const field_registered = try bc.node_registry.register(field.node);
|
||||
field.backendNodeId = field_registered.id;
|
||||
}
|
||||
|
||||
@@ -475,7 +475,7 @@ fn handleDetectForms(server: *Server, arena: std.mem.Allocator, id: std.json.Val
|
||||
const form_registered = try server.node_registry.register(form.node);
|
||||
form.backendNodeId = form_registered.id;
|
||||
|
||||
for (@constCast(form.fields)) |*field| {
|
||||
for (form.fields) |*field| {
|
||||
const field_registered = try server.node_registry.register(field.node);
|
||||
field.backendNodeId = field_registered.id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user