Merge pull request #1656 from lightpanda-io/dump_attribute

Dump Attribute to empty string
This commit is contained in:
Karl Seguin
2026-02-25 18:31:19 +08:00
committed by GitHub
2 changed files with 16 additions and 1 deletions

View File

@@ -172,7 +172,11 @@ fn _deep(node: *Node, opts: Opts, comptime force_slot: bool, writer: *std.Io.Wri
try writer.writeAll(">\n"); try writer.writeAll(">\n");
}, },
.document_fragment => try children(node, opts, writer, page), .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("");
},
} }
} }

View File

@@ -129,3 +129,14 @@
testing.expectEqual(original, serialized); testing.expectEqual(original, serialized);
} }
</script> </script>
<script id=serializeAttribute>
{
const div = document.createElement('div');
div.setAttribute('over', '9000');
const serializer = new XMLSerializer();
const serialized = serializer.serializeToString(div.getAttributeNode('over'));
testing.expectEqual('', serialized);
}
</script>