From 57c8ebdf01fa81fb70177485a61171daef92208b Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Tue, 25 Nov 2014 14:39:46 +0200 Subject: model/graph: __addNode: refactor to use create_node__with_optional_id --- src/model/graph.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/model/graph.js b/src/model/graph.js index 6e6a2411..967c369c 100644 --- a/src/model/graph.js +++ b/src/model/graph.js @@ -27,16 +27,18 @@ function Graph() { * * @param notify whether or not a presenter notification will be sent, default = true */ - this.__addNode = function(node, notify) { - var existing_node; - if (undefined == node.id) { - existing_node = findNodeByName(node.name) + this.__addNode = function(spec, notify) { + var existing_node, + node; + + 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: \'' + node.name + '\''); + console.debug('__addNode: name collision: existing-node.name: \'' + existing_node.name + '\'' + 'new-node.name: \'' + spec.name + '\''); return; }else{ - node = model_core.create_node__set_random_id(node); + node = model_core.create_node__set_random_id(spec); if (debug) { if ('bubble' == node.type){ console.debug('__addNode: stamping node id: ' + node.id + ', name: \'' + node.name + '\' (bubble)'); @@ -45,6 +47,8 @@ function Graph() { } } } + } else { + node = model_core.create_node__with_optional_id(spec); } existing_node = findNode(node.id, null); -- cgit v1.3.1