From f6e20a0b755f248a922483138c19bbc091bbdad3 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Sun, 20 Jan 2008 20:03:42 +0000 Subject: [PATCH] Fix for Projection.equals fails when passed 'null'. r=pagameba (Closes #1286) git-svn-id: http://svn.openlayers.org/trunk/openlayers@5825 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Projection.js | 6 +++++- tests/test_Projection.html | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Projection.js b/lib/OpenLayers/Projection.js index 3209b361ef..e12d108dd1 100644 --- a/lib/OpenLayers/Projection.js +++ b/lib/OpenLayers/Projection.js @@ -89,7 +89,11 @@ OpenLayers.Projection = OpenLayers.Class({ * {Boolean} The two projections are equivalent. */ equals: function(projection) { - return this.getCode() == projection.getCode(); + if (projection && projection.getCode) { + return this.getCode() == projection.getCode(); + } else { + return false; + } }, /* Method: destroy diff --git a/tests/test_Projection.html b/tests/test_Projection.html index c37aafa56c..a98dd57516 100644 --- a/tests/test_Projection.html +++ b/tests/test_Projection.html @@ -18,6 +18,9 @@ out = OpenLayers.Projection.transform({'x':10,'y':12}, projection, projection2); t.eq(out.x, 10, "Null transform has no effect"); t.eq(out.y, 12, "Null transform has no effect"); + + t.eq(projection.equals(null), false, "equals on null projection returns false"); + t.eq(projection.equals({}), false, "equals on null projection object returns false (doesn't call getCode)"); }