chiark / gitweb /
OK, now it doesn't.
authorSimon Tatham <anakin@pobox.com>
Sat, 23 Dec 2023 20:35:50 +0000 (20:35 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 23 Dec 2023 20:35:50 +0000 (20:35 +0000)
Looks as if the only problem there was trying to link the document
root to itself.

src/html.rs

index 6a01cd8cb2295ec3812a6bbfc8539a99bc4f97f2..39525780df2f9a271fba73a89c9a5fe758804981 100644 (file)
@@ -153,6 +153,7 @@ impl TreeSink for Tree {
     fn append(&mut self, parent: &Handle, child: NodeOrText<Handle>) {
         let parent = *parent;
         let child = self.not2handle(child);
+        if parent == child { return }
         let check_index = {
             let children = match self.nodes[parent].contents {
                 TreeNodeContents::Element {
@@ -290,6 +291,5 @@ fn render_read(mut input: impl std::io::Read) -> Tree {
 
 pub fn render<R: Receiver>(html: &str, receiver: &mut R) {
     let tree = render_read(html.as_bytes());
-    dbg!(&tree);
     tree.walk_recurse(0, receiver);
 }