mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-31 01:09:22 +02:00
Graph#rebase must invalidate transients
This commit is contained in:
@@ -140,6 +140,8 @@ iD.Graph.prototype = {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.transients = {};
|
||||
},
|
||||
|
||||
// Updates calculated properties (parentWays, parentRels) for the specified change
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
Reference in New Issue
Block a user