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 @@
+
+