Q:

Javascript InfoVis Toolkit: Event returns wrong node in function that ensues

I stumbled upon the following problem with the Javascript InfoVis Toolkit's Spacetree visualization: When I click a node with the right mouse button, the action which ensues operates on a different node in the same subtree than the one which actually has been clicked.
Here is the relevant portion of code:
st = new $jit.ST({

    Events: {  
        enable: true,
        onRightClick: function(node, eventInfo, e) {
            console.log(eventInfo); // line 87
            console.log(e); // line 88
            if (node != undefined) {
                console.log(node.id); // line 90
                if (removedNodes.indexOf(node.data.uniqueId)>-1) {
                    console.log(node.id, " has been restored");
                    removedNodes.splice(removedNodes.indexOf(node.data.uniqueId),1);
                } else {
                    console.log(node.id, " has been deleted"); // line 95
                    removedNodes.push(node.data.uniqueId);
                }
                localStorage.setItem("removedNodes", JSON.stringify(removedNodes));
                loadNewTree(currentTreeId, true, 0)
            }
        },
    },
    /* further code */
}

As you can see, I put the event info and node ID of the target node to console output (the relevant line numbers marked in the code snippet above). Here is the console output for a case where the wrong node is targeted:

I'm stuck on this problem and don't see what could have gone wrong. The problem occurs approximately once in ten clicks, if clicking nodes from the same subtree, frequently (but not always!) the targeted node is the one which has been clicked one click earlier.
Thanks for any input!

A:

Found a hack to work around the problem: Take the node ID directly from the event:
let Node = st.graph.getNode(e.target.attributes.id.nodeValue);

and then use the newly defined Node rather than the misbehaving node.

