From fd32d488fa0a2d8e35d8119fad78b4c81304ba5d Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Tue, 25 Nov 2014 20:55:46 +0200 Subject: graph/__addNode: fix to handle same node reference It now returns a node, either a new one or the existing one. This is used by addNode and further up to get the existing (regressed until this patch from the breaking patch) behavior of expanding existing nodes with new links. --- src/model/graph.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/model/graph.js b/src/model/graph.js index e2c1b9d1..3fefc6c7 100644 --- a/src/model/graph.js +++ b/src/model/graph.js @@ -34,10 +34,8 @@ function Graph() { if (undefined == spec.id) { existing_node = findNodeByName(spec.name) if (existing_node){ - // FIXME handle node-with-equal-name case - console.debug('__addNode: name collision: existing-node.name: \'' + existing_node.name + '\'' + 'new-node.name: \'' + spec.name + '\''); - return; - }else{ + return existing_node; + } else { node = model_core.create_node__set_random_id(spec); if (debug) { if ('bubble' == node.type){ @@ -53,8 +51,8 @@ function Graph() { existing_node = findNode(node.id, null); if (existing_node) { - console.debug('__addNode: id collision: existing-node.id: \'' + existing_node.id + '\' ' + 'new-node.id: \'' + node.id + '\''); - return; + console.debug('__addNode: id collision: existing-node.id: \'' + existing_node.id + '\', ' + 'new-node.id: \'' + node.id + '\''); + return existing_node; } undefined === notify && (notify = true); // notify by default -- cgit v1.3.1