aboutsummaryrefslogtreecommitdiff
path: root/src/eval/Root.zig
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2026-04-30 17:56:55 +0200
committerAnhgelus Morhtuuzh <william@herges.fr>2026-04-30 17:56:55 +0200
commita13df3ca580dc31544ef092d5d37e18089af3517 (patch)
treecfcf8c1d8322ee8e97783e263105eac9f5c00f33 /src/eval/Root.zig
parent5ecd48d4b9f928beb4143f88e802ee4d9e25a2bd (diff)
refactor(element): generalize element creation
Diffstat (limited to 'src/eval/Root.zig')
-rw-r--r--src/eval/Root.zig10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/eval/Root.zig b/src/eval/Root.zig
index 048dd3b..15c03e8 100644
--- a/src/eval/Root.zig
+++ b/src/eval/Root.zig
@@ -42,25 +42,19 @@ pub fn append(self: *Self, raw: anytype) void {
}
pub fn element(self: *Self) Element {
- return .{ .vtable = .{ .html = html, .node = getNode }, .ptr = self };
+ return Element.Wrapper(Self, html).init(self);
}
pub fn renderHTML(self: *Self, alloc: Allocator) HTML.Error![]const u8 {
return try self.element().renderHTML(alloc);
}
-fn getNode(context: *anyopaque) *Node {
- const self: *Self = @ptrCast(@alignCast(context));
- return &self.node;
-}
-
fn fromNode(context: *anyopaque) Element {
const self: *Self = @ptrCast(@alignCast(context));
return self.element();
}
-fn html(context: *anyopaque, alloc: Allocator) HTML.Error!HTML {
- const self: *Self = @ptrCast(@alignCast(context));
+fn html(self: *Self, alloc: Allocator) HTML.Error!HTML {
const el = try HTML.Root.init(alloc);
var v = self.content.first;
while (v) |it| : (v = it.next) try el.append(Node.from(it).element());