Don't dispatch 'change' on history.merged, dispatch 'merge' only

Change performs an expensive immediate redraw, and merge can schedule
a redraw for later.
This commit is contained in:
Bryan Housel
2019-04-12 09:56:18 -04:00
parent 2b050549eb
commit 0dd262d1dd
3 changed files with 6 additions and 6 deletions

View File

@@ -123,7 +123,6 @@ export function coreHistory(context) {
_stack[0].graph.rebase(entities, stack, false);
_tree.rebase(entities, false);
dispatch.call('change', this, undefined, extent);
dispatch.call('merge', this, entities);
},

View File

@@ -112,6 +112,7 @@ export function rendererMap(context) {
}
context.history()
.on('merge.map', function() { scheduleRedraw(); })
.on('change.map', immediateRedraw)
.on('undone.map', function(stack, fromStack) {
didUndoOrRedo(stack, fromStack.transform);

View File

@@ -28,11 +28,11 @@ describe('iD.coreHistory', function () {
expect(history.graph().entity('n')).to.equal(n);
});
it('emits a change event with the specified extent', function () {
var extent = {};
history.on('change', spy);
history.merge([], extent);
expect(spy).to.have.been.calledWith(undefined, extent);
it('emits a merge event with the new entities', function () {
var n = iD.osmNode({id: 'n'});
history.on('merge', spy);
history.merge([n]);
expect(spy).to.have.been.calledWith([n]);
});
});