RazrFalcon / rctree

A "DOM-like" tree implemented using reference counting
MIT License
36 stars 10 forks source link

Root is not updated on descendents when inserting a node that already has children #14

Closed windexlight closed 3 years ago

windexlight commented 3 years ago

A node that already has children will not have the root updated on its children when it is inserted into a tree.

For example, the below test will fail on the last assertion. Is this intentional (maybe to save time not having to walk descendants), or is this an oversight?

#[test]
fn root_5() {
    let mut node1 = Node::new("node1");
    let mut node2 = Node::new("node2");
    let node3 = Node::new("node3");
    node2.append(node3.clone());
    node1.append(node2.clone());
    assert_eq!(node1.root(), node1);
    assert_eq!(node2.root(), node1);
    assert_eq!(node3.root(), node1);
}
RazrFalcon commented 3 years ago

Yes, this is a bug.