From ede561080dccd87562d546d6cee1474cdb498da9 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Fri, 29 Jun 2018 22:47:14 -0400 Subject: [PATCH] Add update method, remove getters.. This makes the osmNote work a bit more like other osm objects in iD. - When working with the osm objects, we'll treat them as immutable. So all modifications will be through the update method: e.g. can do this in a repl, like chrome devtools console: > n = iD.osmNote() osmNote { id: -1 } > n = n.update({ foo: 'bar' }); osmNote { foo: "bar", id: -1, v: 1 } - none of the other osm objects have getters, and in JavaScript all the properties are public anyway --- modules/osm/note.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/modules/osm/note.js b/modules/osm/note.js index 135d7e599..a9cd67b89 100644 --- a/modules/osm/note.js +++ b/modules/osm/note.js @@ -49,15 +49,7 @@ _extend(osmNote.prototype, { return new geoExtent(this.loc); }, - getID: function() { - return this.id; - }, - - getType: function() { - return this.type; - }, - - getComments: function() { - return this.comments; + update: function(attrs) { + return osmNote(this, attrs, {v: 1 + (this.v || 0)}); } });