When I create a child node using an interpolated string I am unable to access that node again using dot notation. When I try to access the node in question I just get null
. I can get the node if I loop through children()
and hunt for it, but I shouldn't have to do that. The following code duplicates the problem:
// All works as expected when an interpolated string isn't used to create the child node
def rootNode = new Node(null, "root")
def childNode = new Node(rootNode, "child", [attr: "test"])
def childNodeCopy = rootNode.child[0]
println childNode.toString() // child[attributes={attr=test}; value=[]]
println childNodeCopy.toString() // child[attributes={attr=test}; value=[]]
println childNode.toString() == childNodeCopy.toString() // true
// But when an interpolated string is used the child node cannot be accessed from the root
rootNode = new Node(null, "root")
def childName = "child"
childNode = new Node(rootNode, "$childName", [attr: "test"])
childNodeCopy = rootNode.child[0]
println childNode.toString() // child[attributes={attr=test}; value=[]]
println childNodeCopy.toString() // null
println childNode.toString() == childNodeCopy.toString() // false