mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-16 08:18:59 +00:00
node: cast the libdom document depending its type
This commit is contained in:
@@ -75,7 +75,14 @@ pub const Node = struct {
|
|||||||
.text => .{ .Text = @as(*parser.Text, @ptrCast(node)) },
|
.text => .{ .Text = @as(*parser.Text, @ptrCast(node)) },
|
||||||
.cdata_section => .{ .CDATASection = @as(*parser.CDATASection, @ptrCast(node)) },
|
.cdata_section => .{ .CDATASection = @as(*parser.CDATASection, @ptrCast(node)) },
|
||||||
.processing_instruction => .{ .ProcessingInstruction = @as(*parser.ProcessingInstruction, @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)) },
|
.document_type => .{ .DocumentType = @as(*parser.DocumentType, @ptrCast(node)) },
|
||||||
.attribute => .{ .Attr = @as(*parser.Attribute, @ptrCast(node)) },
|
.attribute => .{ .Attr = @as(*parser.Attribute, @ptrCast(node)) },
|
||||||
.document_fragment => .{ .DocumentFragment = @as(*parser.DocumentFragment, @ptrCast(node)) },
|
.document_fragment => .{ .DocumentFragment = @as(*parser.DocumentFragment, @ptrCast(node)) },
|
||||||
|
|||||||
Reference in New Issue
Block a user