From 21ef3e4ce1fde56cfd33a32bb6030f29548058cc Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 26 Nov 2012 21:08:33 -0400 Subject: [PATCH] Flag accidental mutations in tests --- js/iD/graph/Entity.js | 7 ++++++- js/iD/graph/Graph.js | 9 ++++++++- test/index.html | 4 ++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/js/iD/graph/Entity.js b/js/iD/graph/Entity.js index acbdb1dd6..ff3208473 100644 --- a/js/iD/graph/Entity.js +++ b/js/iD/graph/Entity.js @@ -1,11 +1,16 @@ iD.Entity = function(a, b) { if (!(this instanceof iD.Entity)) return new iD.Entity(a, b); - _.extend(this, a, b); + _.extend(this, {tags: {}}, a, b); if (b) { this.modified = true; } + + if (iD.debug) { + Object.freeze(this); + Object.freeze(this.tags); + } }; iD.Entity.prototype = { diff --git a/js/iD/graph/Graph.js b/js/iD/graph/Graph.js index ef492a005..1708218ec 100644 --- a/js/iD/graph/Graph.js +++ b/js/iD/graph/Graph.js @@ -1,6 +1,9 @@ iD.Graph = function(entities, annotation) { if (!(this instanceof iD.Graph)) return new iD.Graph(entities, annotation); + this.entities = entities || {}; + this.annotation = annotation; + for (var id in this.entities) { // TODO: update extents that need it. if (this.entities[id].type === 'way' && !this.entities[id]._extent) { @@ -16,7 +19,11 @@ iD.Graph = function(entities, annotation) { this.entities[id]._extent = extent; } } - this.annotation = annotation; + + if (iD.debug) { + Object.freeze(this); + Object.freeze(this.entities); + } }; iD.Graph.prototype = { diff --git a/test/index.html b/test/index.html index 01f6316ef..33d842123 100644 --- a/test/index.html +++ b/test/index.html @@ -53,6 +53,10 @@ + +