mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-25 17:37:49 +02:00
Use object.create for graph.entities
This commit is contained in:
+1
-1
@@ -164,7 +164,7 @@ iD.Connection = function() {
|
||||
}
|
||||
}
|
||||
|
||||
for (i in g.entities) {
|
||||
for (i in entities) {
|
||||
if (entities[i].type === 'node') {
|
||||
g.transient(entities[i], 'poi', d3.functor(false));
|
||||
}
|
||||
|
||||
@@ -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 = {};
|
||||
this.entities = Object.create(this.original);
|
||||
for (var i = 0; i < entities.length; i++) {
|
||||
this.entities[entities[i].id] = entities[i];
|
||||
}
|
||||
} else {
|
||||
this.entities = entities || {};
|
||||
this.entities = _.extend(Object.create(this.original), entities);
|
||||
}
|
||||
|
||||
this.transients = {};
|
||||
@@ -21,6 +21,9 @@ iD.Graph = function(entities, mutable) {
|
||||
};
|
||||
|
||||
iD.Graph.prototype = {
|
||||
|
||||
original: {},
|
||||
|
||||
entity: function(id) {
|
||||
return this.entities[id];
|
||||
},
|
||||
@@ -86,9 +89,10 @@ iD.Graph.prototype = {
|
||||
},
|
||||
|
||||
merge: function(graph) {
|
||||
return this.update(function () {
|
||||
_.defaults(this.entities, graph.entities);
|
||||
});
|
||||
for (var i in graph.entities) {
|
||||
this.original[i] = graph.entities[i];
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
replace: function(entity) {
|
||||
|
||||
@@ -31,9 +31,7 @@ iD.History = function() {
|
||||
},
|
||||
|
||||
merge: function (graph) {
|
||||
for (var i = 0; i < stack.length; i++) {
|
||||
stack[i].graph = stack[i].graph.merge(graph);
|
||||
}
|
||||
stack[0].graph.merge(graph);
|
||||
},
|
||||
|
||||
perform: function () {
|
||||
|
||||
Reference in New Issue
Block a user