Skip to content
This repository has been archived by the owner on Mar 16, 2020. It is now read-only.

Commit

Permalink
Fix: Update child's parent node when appending
Browse files Browse the repository at this point in the history
  • Loading branch information
raquo committed Feb 1, 2020
1 parent 1b0be15 commit 33ef123
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ trait ParentNode[N, +Ref <: BaseRef, BaseRef] extends Node[N, Ref, BaseRef] { th
val appended = treeApi.appendChild(parent = this, child = child)
if (appended) {

// 2. Update this node
// 2A. Update child's current parent node
child.maybeParent.foreach { childParent =>
childParent._maybeChildren.foreach(childParentChildren => childParentChildren -= child)
}

// 2B. Update this node
if (_maybeChildren.isEmpty) {
_maybeChildren = Some(mutable.Buffer(child))
} else {
Expand Down

0 comments on commit 33ef123

Please sign in to comment.