From 25298a32fa40129b079acf2a0d22a205aa75fafe Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Wed, 25 Feb 2026 18:16:13 +0800 Subject: [PATCH] Dump Attribute to empty string This is normally not called in "normal" dump-usage, but with XMLSerializer.serializeToString an Attr node _can_ be provided. The spec says, and FF agrees, this should return an empty string. --- src/browser/dump.zig | 6 +++++- src/browser/tests/xmlserializer.html | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/browser/dump.zig b/src/browser/dump.zig index e4d0fa05..0f20b06b 100644 --- a/src/browser/dump.zig +++ b/src/browser/dump.zig @@ -172,7 +172,11 @@ fn _deep(node: *Node, opts: Opts, comptime force_slot: bool, writer: *std.Io.Wri try writer.writeAll(">\n"); }, .document_fragment => try children(node, opts, writer, page), - .attribute => unreachable, + .attribute => { + // Not called normally, but can be called via XMLSerializer.serializeToString + // in which case it should return an empty string + try writer.writeAll(""); + }, } } diff --git a/src/browser/tests/xmlserializer.html b/src/browser/tests/xmlserializer.html index edbc60c8..0b8b7272 100644 --- a/src/browser/tests/xmlserializer.html +++ b/src/browser/tests/xmlserializer.html @@ -129,3 +129,14 @@ testing.expectEqual(original, serialized); } + +