diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2026-04-30 17:25:04 +0200 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2026-04-30 17:25:04 +0200 |
| commit | 103efd52b59f77fbfde6a1b7daf65b16c2c26810 (patch) | |
| tree | 722f7be1ea5ffc36fb5d17aab0fb64cb6cb28665 /src/eval/html/Element.zig | |
| parent | 987bd9323a384e8f042311262d9b0e0eba38da15 (diff) | |
refactor(html): supports more type in root append
Diffstat (limited to 'src/eval/html/Element.zig')
| -rw-r--r-- | src/eval/html/Element.zig | 12 |
1 files changed, 6 insertions, 6 deletions
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(), "<p>hello world</p>"); @@ -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(), "<div class=\"foo-bar\"><p>hello world</p><br></div>"); } |
