All geometry equals methods now work with bad arguments (closes #1041).

git-svn-id: http://svn.openlayers.org/trunk/openlayers@4707 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2007-10-01 01:03:29 +00:00
parent 7ce4621042
commit a1d3f20632
2 changed files with 8 additions and 1 deletions
+2 -1
View File
@@ -288,7 +288,8 @@ OpenLayers.Geometry.Collection = OpenLayers.Class(OpenLayers.Geometry, {
*/ */
equals: function(geometry) { equals: function(geometry) {
var equivalent = true; 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; equivalent = false;
} else if(!(geometry.components instanceof Array) || } else if(!(geometry.components instanceof Array) ||
(geometry.components.length != this.components.length)) { (geometry.components.length != this.components.length)) {
+6
View File
@@ -132,6 +132,12 @@
t.eq(coll.bounds.top, 70, "good top bounds"); 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) { function test_07_Collection_addComponent(t) {
t.plan(10); t.plan(10);