Handle entities that are already deleted (fixes #672)

This commit is contained in:
John Firebaugh
2013-02-07 13:46:06 -08:00
parent 189412398e
commit e1bc78871b
2 changed files with 13 additions and 1 deletions
+4 -1
View File
@@ -7,7 +7,10 @@ iD.actions.DeleteMultiple = function(ids) {
};
ids.forEach(function (id) {
graph = actions[graph.entity(id).type](id)(graph);
var entity = graph.entity(id);
if (entity) { // It may have been deleted aready.
graph = actions[entity.type](id)(graph);
}
});
return graph;
+9
View File
@@ -9,4 +9,13 @@ describe("iD.actions.DeleteMultiple", function () {
expect(graph.entity(w.id)).to.be.undefined;
expect(graph.entity(r.id)).to.be.undefined;
});
it("deletes a way and one of its nodes", function () {
var n = iD.Node(),
w = iD.Way({nodes: [n.id]}),
action = iD.actions.DeleteMultiple([w.id, n.id]),
graph = action(iD.Graph([n, w]));
expect(graph.entity(w.id)).to.be.undefined;
expect(graph.entity(n.id)).to.be.undefined;
});
});