From dca42e27fe9c7d28c72bb6cb8e5cc4ec481572e8 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Sun, 26 Apr 2026 21:38:06 +0200 Subject: feat(): support image --- src/eval/html/Element.zig | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'src/eval/html/Element.zig') diff --git a/src/eval/html/Element.zig b/src/eval/html/Element.zig index 87fd876..666e6f0 100644 --- a/src/eval/html/Element.zig +++ b/src/eval/html/Element.zig @@ -178,19 +178,6 @@ pub fn appendContent(self: *Self, content: Self) Error!void { return self.content.append(alloc, content); } -pub fn initImg(alloc: Allocator, src: []const u8, alt: []const u8) Error!Self { - var el = try init(alloc, .void, "img"); - try el.setAttribute("src", src); - try el.setAttribute("alt", alt); - return el; -} - -pub fn initContent(alloc: Allocator, tag: []const u8, content: []Self) Error!Self { - var el = try init(alloc, .content, tag); - for (content) |it| try el.appendContent(it); - return el; -} - fn doTest(alloc: Allocator, el: *Self, exp: []const u8) !void { const got = try el.render(alloc); defer alloc.free(got); @@ -214,10 +201,6 @@ test "void element" { try img.setAttribute("alt", "bar"); try doTest(alloc, &img, "\"bar\""); - - var img2 = try initImg(alloc, "foo", "bar"); - defer img2.deinit(); - try doTest(alloc, &img2, "\"bar\""); } test "content element" { @@ -235,7 +218,7 @@ test "content element" { defer div.deinit(); try div.appendClass("foo-bar"); try div.appendContent(p); - try div.appendContent(try initImg(alloc, "example.org", "example")); + try div.appendContent(try init(alloc, .void, "br")); - try doTest(alloc, &div, "

hello world

\"example\"
"); + try doTest(alloc, &div, "

hello world


"); } -- cgit v1.2.3