From 29378c57ea092a8a226eeb3ee4404bf2f7ce14ef Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Thu, 7 Aug 2025 12:54:18 +0200 Subject: [PATCH] node: cast the libdom document depending its type --- src/browser/dom/node.zig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/browser/dom/node.zig b/src/browser/dom/node.zig index 25c15431..08c8f42e 100644 --- a/src/browser/dom/node.zig +++ b/src/browser/dom/node.zig @@ -75,7 +75,14 @@ pub const Node = struct { .text => .{ .Text = @as(*parser.Text, @ptrCast(node)) }, .cdata_section => .{ .CDATASection = @as(*parser.CDATASection, @ptrCast(node)) }, .processing_instruction => .{ .ProcessingInstruction = @as(*parser.ProcessingInstruction, @ptrCast(node)) }, - .document => .{ .HTMLDocument = @as(*parser.DocumentHTML, @ptrCast(node)) }, + .document => blk: { + const doc: *parser.Document = @ptrCast(node); + if (doc.is_html) { + break :blk .{ .HTMLDocument = @as(*parser.DocumentHTML, @ptrCast(node)) }; + } + + break :blk .{ .Document = doc }; + }, .document_type => .{ .DocumentType = @as(*parser.DocumentType, @ptrCast(node)) }, .attribute => .{ .Attr = @as(*parser.Attribute, @ptrCast(node)) }, .document_fragment => .{ .DocumentFragment = @as(*parser.DocumentFragment, @ptrCast(node)) },