Skip to content

Commit

Permalink
Merge pull request #499 from Sharktheone/remove-empty-text
Browse files Browse the repository at this point in the history
remove empty text nodes from tree in `remove_unrenderable_nodes`
  • Loading branch information
Sharktheone committed Jun 25, 2024
2 parents 27241dc + a7b3440 commit 85beba4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions crates/gosub_styling/src/render_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,21 @@ impl<B: RenderBackend> RenderTree<B> {
}
}

if let RenderNodeData::Text(t) = &node.data {
let mut remove = true;
for c in t.prerender.value().chars() {
if !c.is_ascii_whitespace() {
remove = false;
break;
}
}

if remove {
delete_list.push(*id);
continue;
}
}

// Check CSS styles and remove if not renderable
if let Some(mut prop) = self.get_property(*id, "display") {
if prop.compute_value().to_string() == "none" {
Expand Down

0 comments on commit 85beba4

Please sign in to comment.