mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
Copy entity in Graph#fetch
This shouldn't be necessary, but someone is modifying them in place and it's causing problems elsewhere.
This commit is contained in:
@@ -89,7 +89,7 @@ iD.Graph.prototype = {
|
||||
// Resolve the id references in a way, replacing them with actual objects.
|
||||
fetch: function(id) {
|
||||
var entity = this.entities[id], nodes = [];
|
||||
if (!entity.nodes || !entity.nodes.length) return entity;
|
||||
if (!entity.nodes || !entity.nodes.length) return iD.Entity(entity); // TODO: shouldn't be necessary
|
||||
for (var i = 0, l = entity.nodes.length; i < l; i++) {
|
||||
nodes[i] = this.fetch(entity.nodes[i]);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ describe('Graph', function() {
|
||||
var node = iD.Node({id: "n1"}),
|
||||
way = iD.Way({id: "w1", nodes: ["n1"]}),
|
||||
graph = iD.Graph({n1: node, w1: way});
|
||||
expect(graph.fetch("w1").nodes).to.eql([node]);
|
||||
expect(graph.fetch("w1").nodes[0].id).to.equal("n1");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user