sjbarag / brs

An interpreter for the BrightScript language that runs on non-Roku platforms.
MIT License
113 stars 43 forks source link

Reparent (ifSGNodeChildren function) does not add child node to the new parent #644

Closed underwoo16 closed 3 years ago

underwoo16 commented 3 years ago

When calling child.reparent(newParentNode, false) the child's parent is updated but the newParentNode does not add child to its list of children. Example script below:

sub main()
    testParent = createObject("roSGNode", "Node")
    testParent.id = "test-parent"

    testChild = createObject("roSGNode", "Node")
    testChild.id = "test-child"

    print "children before reparent:"
    print testParent.getChildren(-1, 0)

    print "parent before reparent":
    print testChild.getParent()

    testChild.reparent(testParent, false)

    print "children after reparent:"
    print testParent.getChildren(-1, 0)

    print "parent after reparent":
    print testChild.getParent()
end sub

Which creates the following output. Note how the children array is empty before and after the call to reparent:

children before reparent:
<Component: roArray> =
[
]
parent before reparent
invalid
children after reparent:
<Component: roArray> =
[
]
parent after reparent
<Component: roSGNode:Node> =
{
    change: <Component: roAssociativeArray>
    focusable: false
    focusedchild: invalid
    id: test-parent
}