diff --git a/crates/gosub_render_utils/src/render_tree/desc.rs b/crates/gosub_render_utils/src/render_tree/desc.rs index 7ae505fd..bc5fd65f 100644 --- a/crates/gosub_render_utils/src/render_tree/desc.rs +++ b/crates/gosub_render_utils/src/render_tree/desc.rs @@ -4,6 +4,7 @@ use gosub_render_backend::{NodeDesc, Point, Size}; use gosub_shared::node::NodeId; use gosub_shared::traits::css3::{CssPropertyMap, CssSystem}; use gosub_shared::traits::document::Document; +use gosub_shared::traits::node::{ElementDataType, Node}; impl, C: CssSystem> RenderTree { pub fn desc(&self) -> NodeDesc { @@ -27,14 +28,23 @@ impl, C: CssSystem> RenderTree { let attributes = if let RenderNodeData::Element = &node.data { // we need to get the attributes from the document, not from the render tree - todo!("attributes") + if let Some(handle) = &self.handle { + let doc = handle.get(); - // e.attributes - // .iter() - // .map(|(k, v)| (k.clone(), v.clone())) - // .collect() + doc.node_by_id(node.id) + .and_then(|n| n.get_element_data()) + .map(|e| e.attributes()) + .map(|a| { + a.iter() + .map(|(k, v)| (k.clone(), v.clone())) + .collect::>() + }) + .unwrap_or_default() + } else { + Vec::new() + } } else { - vec![] + Vec::new() }; let (name, text) = if let RenderNodeData::Text(t) = &node.data {