aboutsummaryrefslogtreecommitdiff
path: root/src/dom
diff options
context:
space:
mode:
Diffstat (limited to 'src/dom')
-rw-r--r--src/dom/Element.zig10
-rw-r--r--src/dom/html.zig2
2 files changed, 6 insertions, 6 deletions
diff --git a/src/dom/Element.zig b/src/dom/Element.zig
index 0cbddc4..524586c 100644
--- a/src/dom/Element.zig
+++ b/src/dom/Element.zig
@@ -21,7 +21,7 @@ literal: ?[]const u8 = null,
/// Init a new Element with the given kind.
/// The tag will never be escaped.
-/// The owernship is always taken.
+/// It always duplicates strings.
pub fn init(alloc: Allocator, knd: Kind, tag: []const u8) !Self {
var v = Self{
.kind = knd,
@@ -36,7 +36,7 @@ pub fn init(alloc: Allocator, knd: Kind, tag: []const u8) !Self {
/// Init a new literal element.
/// The literal content will never be escaped, see initLitEscaped if you want to escape it.
-/// The owernship is always taken.
+/// It always duplicates strings.
pub fn initLit(alloc: Allocator, literal: []const u8) !Self {
var v = Self{
.kind = .literal,
@@ -51,7 +51,7 @@ pub fn initLit(alloc: Allocator, literal: []const u8) !Self {
/// Init a new literal element that is escaped.
/// The literal content will be escaped, see initLit if you don't want this behavior.
-/// The owernship is always taken.
+/// It always duplicates strings.
pub fn initLitEscaped(alloc: Allocator, literal: []const u8) !Self {
const escaped = try html.escape(alloc, literal);
defer alloc.free(escaped);
@@ -198,7 +198,7 @@ fn doTest(alloc: Allocator, el: *Self, exp: []const u8) !void {
test "void element" {
var arena = std.heap.DebugAllocator(.{}).init;
- defer _ = arena.deinit();
+ defer if (arena.deinit() == .leak) std.debug.print("leaking!\n", .{});
const alloc = arena.allocator();
var br = try init(alloc, .void, "br");
@@ -220,7 +220,7 @@ test "void element" {
test "content element" {
var arena = std.heap.DebugAllocator(.{}).init;
- defer _ = arena.deinit();
+ defer if (arena.deinit() == .leak) std.debug.print("leaking!\n", .{});
const alloc = arena.allocator();
var p = try init(alloc, .content, "p");
diff --git a/src/dom/html.zig b/src/dom/html.zig
index 47de020..a3178f2 100644
--- a/src/dom/html.zig
+++ b/src/dom/html.zig
@@ -35,7 +35,7 @@ fn doTest(alloc: std.mem.Allocator, el: []const u8, exp: []const u8) !void {
test "escaping html" {
var arena = std.heap.DebugAllocator(.{}).init;
- defer _ = arena.deinit();
+ defer if (arena.deinit() == .leak) std.debug.print("leaking!\n", .{});
const alloc = arena.allocator();
try doTest(alloc, "hello world", "hello world");