diff --git a/js/id/core/graph.js b/js/id/core/graph.js index 5b5d0a26c..ec388756b 100644 --- a/js/id/core/graph.js +++ b/js/id/core/graph.js @@ -140,6 +140,8 @@ iD.Graph.prototype = { } } } + + this.transients = {}; }, // Updates calculated properties (parentWays, parentRels) for the specified change diff --git a/test/spec/core/graph.js b/test/spec/core/graph.js index 5eb504ac5..4894ba63e 100644 --- a/test/spec/core/graph.js +++ b/test/spec/core/graph.js @@ -214,6 +214,22 @@ describe('iD.Graph', function() { expect(graph2.parentRelations(n)).to.eql([r1, r2, r3]); }); + it("invalidates transients", function() { + var n = iD.Node({id: 'n'}), + w1 = iD.Way({id: 'w1', nodes: ['n']}), + w2 = iD.Way({id: 'w2', nodes: ['n']}), + graph = iD.Graph([n, w1]); + + function numParents(entity) { + return graph.transient(entity, 'numParents', function() { + return graph.parentWays(entity).length; + }); + } + + expect(numParents(n)).to.equal(1); + graph.rebase({w2: w2}); + expect(numParents(n)).to.equal(2); + }); }); describe("#remove", function () {