Skip to content

Commit

Permalink
fix node desc attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharktheone committed Sep 22, 2024
1 parent 2b45bb6 commit b8e19b1
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions crates/gosub_render_utils/src/render_tree/desc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<L: Layouter, D: Document<C>, C: CssSystem> RenderTree<L, D, C> {
pub fn desc(&self) -> NodeDesc {
Expand All @@ -27,14 +28,23 @@ impl<L: Layouter, D: Document<C>, C: CssSystem> RenderTree<L, D, C> {
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::<Vec<_>>()
})
.unwrap_or_default()
} else {
Vec::new()
}
} else {
vec![]
Vec::new()
};

let (name, text) = if let RenderNodeData::Text(t) = &node.data {
Expand Down

0 comments on commit b8e19b1

Please sign in to comment.