aboutsummaryrefslogtreecommitdiff
path: root/src/eval/html/Content.zig
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2026-04-30 14:33:13 +0200
committerAnhgelus Morhtuuzh <william@herges.fr>2026-04-30 14:33:13 +0200
commit987bd9323a384e8f042311262d9b0e0eba38da15 (patch)
tree852be64f4342f569b991106b8770c75cb160e8ac /src/eval/html/Content.zig
parentc0d1bd44fb6f5ceb5a79fe607cd40444b7aec2e6 (diff)
refactor(html): generalize element creation
Diffstat (limited to 'src/eval/html/Content.zig')
-rw-r--r--src/eval/html/Content.zig10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/eval/html/Content.zig b/src/eval/html/Content.zig
index aed3a0e..96961da 100644
--- a/src/eval/html/Content.zig
+++ b/src/eval/html/Content.zig
@@ -28,12 +28,7 @@ pub fn init(alloc: Allocator, tag: []const u8) Error!*Self {
}
pub fn element(self: *Self) Element {
- return .{ .vtable = .{ .render = render, .node = getNode }, .ptr = self };
-}
-
-fn getNode(context: *anyopaque) *Node {
- const self: *Self = @ptrCast(@alignCast(context));
- return &self.node;
+ return (Element.Wrapper(Self){ .ptr = self }).element();
}
fn fromNode(context: *anyopaque) Element {
@@ -41,8 +36,7 @@ fn fromNode(context: *anyopaque) Element {
return self.element();
}
-fn render(context: *anyopaque, alloc: Allocator) Error![]const u8 {
- const self: *Self = @ptrCast(@alignCast(context));
+pub fn render(self: *Self, alloc: Allocator) Error![]const u8 {
var base = self.base;
const b = try base.element().render(alloc);
defer alloc.free(b);