Skip to content

Commit

Permalink
cloning node should not clone its children
Browse files Browse the repository at this point in the history
  • Loading branch information
jaytaph committed Sep 27, 2023
1 parent 236a7dd commit d940e24
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/html5_parser/parser/adoption_agency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ mod test {

println!("{}", parser.document);

assert!(true);
assert_eq!(true, true);
// let document = parser.document;
// let table = document.get_node_by_id(1).unwrap();
// let tr = document.get_node_by_id(2).unwrap();
Expand Down
8 changes: 5 additions & 3 deletions src/html5_parser/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3107,7 +3107,7 @@ impl<'a> Html5Parser<'a> {
.get_node_by_id(node_id)
.expect("node not found")
.clone();
let new_node_id = self.clone_node(entry_node);
let new_node_id = self.clone_node_without_children(entry_node);

self.active_formatting_elements[entry_index] = ActiveElement::NodeId(new_node_id);

Expand All @@ -3119,8 +3119,10 @@ impl<'a> Html5Parser<'a> {
}
}

fn clone_node(&mut self, org_node: Node) -> usize {
let new_node = org_node.clone();
fn clone_node_without_children(&mut self, org_node: Node) -> usize {
let mut new_node = org_node.clone();
new_node.children = Vec::new();
new_node.parent = None;

let new_node_id = self.document.add_node(new_node, current_node!(self).id);
if let NodeData::Element { .. } = org_node.data {
Expand Down

0 comments on commit d940e24

Please sign in to comment.