diff --git a/src/SemanticTree.zig b/src/SemanticTree.zig index 7927a10f..2ac1ccba 100644 --- a/src/SemanticTree.zig +++ b/src/SemanticTree.zig @@ -38,7 +38,7 @@ page: *Page, arena: std.mem.Allocator, prune: bool = true, interactive_only: bool = false, -max_depth: ?u32 = null, +max_depth: u32 = std.math.maxInt(u32) - 1, pub fn jsonStringify(self: @This(), jw: *std.json.Stringify) error{WriteFailed}!void { var visitor = JsonVisitor{ .jw = jw, .tree = self }; @@ -85,9 +85,7 @@ const NodeData = struct { }; fn walk(self: @This(), node: *Node, xpath_buffer: *std.ArrayList(u8), parent_name: ?[]const u8, visitor: anytype, index: usize, listener_targets: interactive.ListenerTargetMap, current_depth: u32) !void { - if (self.max_depth) |max| { - if (current_depth > max) return; - } + if (current_depth > self.max_depth) return; // 1. Skip non-content nodes if (node.is(Element)) |el| { @@ -497,7 +495,7 @@ test "SemanticTree backendDOMNodeId" { .arena = testing.arena_allocator, .prune = false, .interactive_only = false, - .max_depth = null, + .max_depth = std.math.maxInt(u32) - 1, }; const json_str = try std.json.Stringify.valueAlloc(testing.allocator, st, .{}); diff --git a/src/cdp/domains/lp.zig b/src/cdp/domains/lp.zig index d74dd2de..51b3249d 100644 --- a/src/cdp/domains/lp.zig +++ b/src/cdp/domains/lp.zig @@ -73,7 +73,7 @@ fn getSemanticTree(cmd: anytype) !void { .arena = cmd.arena, .prune = params.prune orelse true, .interactive_only = params.interactiveOnly orelse false, - .max_depth = params.maxDepth, + .max_depth = params.maxDepth orelse std.math.maxInt(u32) - 1, }; if (params.format) |format| { diff --git a/src/mcp/tools.zig b/src/mcp/tools.zig index cb105d25..aefcca83 100644 --- a/src/mcp/tools.zig +++ b/src/mcp/tools.zig @@ -206,7 +206,7 @@ const ToolStreamingText = struct { if (registry.lookup_by_id.get(node_id)) |n| { root_node = n.dom; } else { - log.warn(.mcp, "semantic_tree id missing", .{.id = node_id}); + log.warn(.mcp, "semantic_tree id missing", .{ .id = node_id }); } } } @@ -217,7 +217,7 @@ const ToolStreamingText = struct { .page = self.page, .arena = self.arena.?, .prune = true, - .max_depth = self.maxDepth, + .max_depth = self.maxDepth orelse std.math.maxInt(u32) - 1, }; st.textStringify(w) catch |err| {