diff --git a/js/id/connection.js b/js/id/connection.js index 10b88231e..326e9ebfa 100644 --- a/js/id/connection.js +++ b/js/id/connection.js @@ -164,7 +164,7 @@ iD.Connection = function() { } } - for (i in entities) { + for (i in g.entities) { if (entities[i].type === 'node') { g.transient(entities[i], 'poi', d3.functor(false)); } diff --git a/js/id/graph/graph.js b/js/id/graph/graph.js index bc152270b..120fa2fe7 100644 --- a/js/id/graph/graph.js +++ b/js/id/graph/graph.js @@ -2,12 +2,12 @@ iD.Graph = function(entities, mutable) { if (!(this instanceof iD.Graph)) return new iD.Graph(entities, mutable); if (_.isArray(entities)) { - this.entities = Object.create(this.original); + this.entities = {}; for (var i = 0; i < entities.length; i++) { this.entities[entities[i].id] = entities[i]; } } else { - this.entities = _.extend(Object.create(this.original), entities); + this.entities = entities || {}; } this.transients = {}; @@ -21,9 +21,6 @@ iD.Graph = function(entities, mutable) { }; iD.Graph.prototype = { - - original: {}, - entity: function(id) { return this.entities[id]; }, @@ -101,10 +98,9 @@ iD.Graph.prototype = { }, merge: function(graph) { - for (var i in graph.entities) { - this.original[i] = graph.entities[i]; - } - return this; + return this.update(function () { + _.defaults(this.entities, graph.entities); + }); }, replace: function(entity) { diff --git a/js/id/graph/history.js b/js/id/graph/history.js index 87d637c54..db2afda9e 100644 --- a/js/id/graph/history.js +++ b/js/id/graph/history.js @@ -30,7 +30,9 @@ iD.History = function() { }, merge: function (graph) { - stack[0].graph.merge(graph); + for (var i = 0; i < stack.length; i++) { + stack[i].graph = stack[i].graph.merge(graph); + } }, perform: function () {