Skip to content

Commit

Permalink
Initial style setup
Browse files Browse the repository at this point in the history
  • Loading branch information
jaytaph committed Mar 18, 2024
1 parent faef10b commit 0d64391
Show file tree
Hide file tree
Showing 9 changed files with 888 additions and 776 deletions.
6 changes: 6 additions & 0 deletions crates/gosub_html5/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ pub struct Node {
pub is_registered: bool,
}

impl Node {
pub fn is_root(&self) -> bool {
self.id.is_root()
}
}

impl PartialEq for Node {
fn eq(&self, other: &Node) -> bool {
self.id == other.id
Expand Down
8 changes: 8 additions & 0 deletions crates/gosub_html5/src/parser/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,14 @@ impl Document {
None
}

/// Returns the parent node of the given node, or None when no parent is found
pub fn parent_node(&self, node: &Node) -> Option<&Node> {
match node.parent {
Some(parent_node_id) => self.get_node_by_id(parent_node_id),
None => None,
}
}

pub fn add_new_node(&mut self, node: Node) -> NodeId {
// if a node contains attributes when adding to the tree,
// be sure to handle the special attributes "id" and "class"
Expand Down
Loading

0 comments on commit 0d64391

Please sign in to comment.