diff --git a/js/id/core/history.js b/js/id/core/history.js index 90cb947af..966e4a567 100644 --- a/js/id/core/history.js +++ b/js/id/core/history.js @@ -198,7 +198,7 @@ iD.History = function(context) { }, toJSON: function() { - if (stack.length <= 1) return; + if (!this.hasChanges()) return; var allEntities = {}, baseEntities = {}, diff --git a/test/spec/core/history.js b/test/spec/core/history.js index d8be41a63..4bcd1d477 100644 --- a/test/spec/core/history.js +++ b/test/spec/core/history.js @@ -272,6 +272,13 @@ describe("iD.History", function () { }); describe("#toJSON", function() { + it("doesn't generate unsaveable changes", function() { + var node_1 = iD.Node({id: 'n-1'}); + history.perform(iD.actions.AddEntity(node_1)); + history.perform(iD.actions.DeleteNode('n-1')); + expect(history.toJSON()).to.be.not.ok; + }); + it("generates v3 JSON", function() { var node_1 = iD.Node({id: 'n-1'}), node1 = iD.Node({id: 'n1'}),