diff --git a/lib/OpenLayers/Geometry/Collection.js b/lib/OpenLayers/Geometry/Collection.js index 8c1c589695..94ad5bd709 100644 --- a/lib/OpenLayers/Geometry/Collection.js +++ b/lib/OpenLayers/Geometry/Collection.js @@ -288,7 +288,8 @@ OpenLayers.Geometry.Collection = OpenLayers.Class(OpenLayers.Geometry, { */ equals: function(geometry) { var equivalent = true; - if(!geometry.CLASS_NAME || (this.CLASS_NAME != geometry.CLASS_NAME)) { + if(!geometry || !geometry.CLASS_NAME || + (this.CLASS_NAME != geometry.CLASS_NAME)) { equivalent = false; } else if(!(geometry.components instanceof Array) || (geometry.components.length != this.components.length)) { diff --git a/tests/Geometry/test_Collection.html b/tests/Geometry/test_Collection.html index a64a358a77..36d3e080ac 100644 --- a/tests/Geometry/test_Collection.html +++ b/tests/Geometry/test_Collection.html @@ -132,6 +132,12 @@ t.eq(coll.bounds.top, 70, "good top bounds"); } + function test_Collection_equals(t) { + t.plan(1); + var geom = new OpenLayers.Geometry.Collection(); + t.ok(!geom.equals(), "collection.equals() returns false for undefined"); + } + function test_07_Collection_addComponent(t) { t.plan(10);