From 103efd52b59f77fbfde6a1b7daf65b16c2c26810 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Thu, 30 Apr 2026 17:25:04 +0200 Subject: refactor(html): supports more type in root append --- src/eval/html/Element.zig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/eval/html/Element.zig') diff --git a/src/eval/html/Element.zig b/src/eval/html/Element.zig index c44f4ef..c6197b8 100644 --- a/src/eval/html/Element.zig +++ b/src/eval/html/Element.zig @@ -45,9 +45,9 @@ pub const Node = struct { vtable: struct { element: *const fn (*anyopaque) Element }, node: std.DoublyLinkedList.Node = .{}, - pub fn from(n: *std.DoublyLinkedList.Node) *Node { - const v: *Node = @fieldParentPtr("node", n); - return v; + pub fn from(n: *std.DoublyLinkedList.Node) Element { + const self: *Node = @fieldParentPtr("node", n); + return self.vtable.element(self.ptr); } pub fn element(self: Node) Element { @@ -106,7 +106,7 @@ test "content" { p.content = root.element(); var content = try Literal.init(alloc, "hello world"); - root.append(content.element()); + try root.append(content.element()); try doTest(alloc, content.element(), "hello world"); try doTest(alloc, p.element(), "

hello world

"); @@ -115,8 +115,8 @@ test "content" { var rootDiv = try Root.init(alloc); div.content = rootDiv.element(); try div.base.appendClass("foo-bar"); - rootDiv.append(p.element()); - rootDiv.append((try Void.init(alloc, "br")).element()); + try rootDiv.append(p.element()); + try rootDiv.append((try Void.init(alloc, "br")).element()); try doTest(alloc, div.element(), "

hello world


"); } -- cgit v1.2.3