Skip to content

Commit 29378c5

Browse files
committed
node: cast the libdom document depending its type
1 parent 16c74cf commit 29378c5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/browser/dom/node.zig

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,14 @@ pub const Node = struct {
7575
.text => .{ .Text = @as(*parser.Text, @ptrCast(node)) },
7676
.cdata_section => .{ .CDATASection = @as(*parser.CDATASection, @ptrCast(node)) },
7777
.processing_instruction => .{ .ProcessingInstruction = @as(*parser.ProcessingInstruction, @ptrCast(node)) },
78-
.document => .{ .HTMLDocument = @as(*parser.DocumentHTML, @ptrCast(node)) },
78+
.document => blk: {
79+
const doc: *parser.Document = @ptrCast(node);
80+
if (doc.is_html) {
81+
break :blk .{ .HTMLDocument = @as(*parser.DocumentHTML, @ptrCast(node)) };
82+
}
83+
84+
break :blk .{ .Document = doc };
85+
},
7986
.document_type => .{ .DocumentType = @as(*parser.DocumentType, @ptrCast(node)) },
8087
.attribute => .{ .Attr = @as(*parser.Attribute, @ptrCast(node)) },
8188
.document_fragment => .{ .DocumentFragment = @as(*parser.DocumentFragment, @ptrCast(node)) },

0 commit comments

Comments
 (0)