diff --git a/js/iD/Way.js b/js/iD/Way.js
index acb350a70..c7b1ccb4b 100644
--- a/js/iD/Way.js
+++ b/js/iD/Way.js
@@ -22,8 +22,10 @@ iD.Way = function(connection, id, nodes, tags, loaded) {
this.nodes = [];
this.extent = {};
- for (var i = 0; i < nodes.length; i++) {
- this.addNode(nodes[i]);
+ if (nodes) {
+ for (var i = 0; i < nodes.length; i++) {
+ this.addNode(nodes[i]);
+ }
}
};
@@ -37,8 +39,8 @@ iD.Way.prototype = {
// JOSM: http://josm.openstreetmap.de/browser/josm/trunk/src/org/openstreetmap/josm/data/osm/Way.java#L466
isClosed: function() {
// summary: Is this a closed way (first and last nodes the same)?
- return this.nodes.length > 1 &&
- this.nodes[this.nodes.length - 1] === this.nodes[0];
+ if (!this.nodes.length) return true;
+ return this.nodes[this.nodes.length - 1] === this.nodes[0];
},
isType: function(type) {
diff --git a/test/index.html b/test/index.html
index 3677f52f6..81296a1f8 100644
--- a/test/index.html
+++ b/test/index.html
@@ -11,7 +11,6 @@
-
@@ -20,6 +19,7 @@
+
diff --git a/test/spec/Way.js b/test/spec/Way.js
index 7fc577714..49ffae029 100644
--- a/test/spec/Way.js
+++ b/test/spec/Way.js
@@ -3,6 +3,7 @@ describe('Way', function() {
beforeEach(function() {
way = new iD.Way();
+ console.log(way);
});
it('is a way', function() {
@@ -26,7 +27,7 @@ describe('Way', function() {
});
it('can provide geojson', function() {
- var gj = way.toGeoJSON();
+ var gj = way.toGeoJSON();
expect(gj.type).toEqual('Feature');
expect(gj.geometry.type).toEqual('LineString');
});