From fc00f154a913788b5d16fed1a917a4c3fce80491 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Sat, 2 Feb 2013 19:44:47 -0500 Subject: [PATCH] Dispatch a change event on merge --- js/id/graph/history.js | 2 ++ js/id/renderer/map.js | 1 - test/spec/graph/history.js | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/js/id/graph/history.js b/js/id/graph/history.js index cbadbf87f..3cc1ace01 100644 --- a/js/id/graph/history.js +++ b/js/id/graph/history.js @@ -35,6 +35,8 @@ iD.History = function() { for (var i = 0; i < stack.length; i++) { stack[i].graph.rebase(entities); } + + dispatch.change(); }, perform: function () { diff --git a/js/id/renderer/map.js b/js/id/renderer/map.js index 839aa18a3..c3b528da3 100644 --- a/js/id/renderer/map.js +++ b/js/id/renderer/map.js @@ -102,7 +102,6 @@ iD.Map = function(context) { function connectionLoad(err, result) { context.history().merge(result); - redraw(Object.keys(result)); } function zoomPan() { diff --git a/test/spec/graph/history.js b/test/spec/graph/history.js index 3f28f437e..0ecbed5d3 100644 --- a/test/spec/graph/history.js +++ b/test/spec/graph/history.js @@ -13,6 +13,20 @@ describe("iD.History", function () { }); }); + describe("#merge", function () { + it("merges the entities into all graph versions", function () { + var n = iD.Node({id: 'n'}); + history.merge({n: n}); + expect(history.graph().entity('n')).to.equal(n); + }); + + it("emits a change event", function () { + history.on('change', spy); + history.merge({}); + expect(spy).to.have.been.called; + }); + }); + describe("#perform", function () { it("returns a difference", function () { expect(history.perform(action).changes()).to.eql({});