From ac2a6ae3d8f6156c76b522b10836244988e0393d Mon Sep 17 00:00:00 2001 From: Nico Burns Date: Tue, 8 Oct 2024 13:18:52 +0100 Subject: [PATCH] Print node id's when debug logging the tree --- packages/blitz-dom/src/util.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/blitz-dom/src/util.rs b/packages/blitz-dom/src/util.rs index 8bbbdf21..3e082257 100644 --- a/packages/blitz-dom/src/util.rs +++ b/packages/blitz-dom/src/util.rs @@ -191,34 +191,35 @@ pub fn walk_tree(indent: usize, node: &Node) { } print!("{}", " ".repeat(indent)); + let id = node.id; match &node.raw_dom_data { - NodeData::Document => println!("#Document"), + NodeData::Document => println!("#Document {id}"), NodeData::Text(data) => { if data.content.chars().all(|c| c.is_ascii_whitespace()) { - println!("#text: "); + println!("{id} #text: "); } else { let content = data.content.trim(); if content.len() > 10 { println!( - "#text: {}...", + "#text {id}: {}...", content .split_at(content.char_indices().take(10).last().unwrap().0) .0 .escape_default() ) } else { - println!("#text: {}", data.content.trim().escape_default()) + println!("#text {id}: {}", data.content.trim().escape_default()) } } } - NodeData::Comment => println!(""), + NodeData::Comment => println!(""), - NodeData::AnonymousBlock(_) => println!("AnonymousBlock"), + NodeData::AnonymousBlock(_) => println!("{id} AnonymousBlock"), NodeData::Element(data) => { - print!("<{}", data.name.local); + print!("<{} {id}", data.name.local); for attr in data.attrs.iter() { print!(" {}=\"{}\"", attr.name.local, attr.value); }