[OpenLayers-Commits] r2340 - sandbox/vector-2.4/lib/OpenLayers

commits at openlayers.org commits at openlayers.org
Mon Mar 5 14:46:45 EST 2007


Author: euzuro
Date: 2007-03-05 14:46:43 -0500 (Mon, 05 Mar 2007)
New Revision: 2340

Modified:
   sandbox/vector-2.4/lib/OpenLayers/BaseTypes.js
Log:
do not break if extend() is called with null object

Modified: sandbox/vector-2.4/lib/OpenLayers/BaseTypes.js
===================================================================
--- sandbox/vector-2.4/lib/OpenLayers/BaseTypes.js	2007-03-05 19:44:29 UTC (rev 2339)
+++ sandbox/vector-2.4/lib/OpenLayers/BaseTypes.js	2007-03-05 19:46:43 UTC (rev 2340)
@@ -478,28 +478,30 @@
      */
     extend:function(object) {
         var bounds = null;
-        switch(object.CLASS_NAME) {
-            case "OpenLayers.Geometry.Point":
-            case "OpenLayers.LonLat":    
-                bounds = new OpenLayers.Bounds(object.lon, object.lat,
-                                                object.lon, object.lat);
-                break;
-                
-            case "OpenLayers.Bounds":    
-                bounds = object;
-               break;
+        if (object) {
+            switch(object.CLASS_NAME) {
+                case "OpenLayers.Geometry.Point":
+                case "OpenLayers.LonLat":    
+                    bounds = new OpenLayers.Bounds(object.lon, object.lat,
+                                                    object.lon, object.lat);
+                    break;
+                    
+                case "OpenLayers.Bounds":    
+                    bounds = object;
+                   break;
+            }
+    
+            if (bounds) {
+               this.left = (bounds.left < this.left) ? bounds.left 
+                                                     : this.left;
+               this.bottom = (bounds.bottom < this.bottom) ? bounds.bottom 
+                                                           : this.bottom;
+               this.right = (bounds.right > this.right) ? bounds.right 
+                                                        : this.right;
+               this.top = (bounds.top > this.top) ? bounds.top 
+                                                  : this.top;
+            }
         }
-
-        if (bounds) {
-           this.left = (bounds.left < this.left) ? bounds.left 
-                                                 : this.left;
-           this.bottom = (bounds.bottom < this.bottom) ? bounds.bottom 
-                                                       : this.bottom;
-           this.right = (bounds.right > this.right) ? bounds.right 
-                                                    : this.right;
-           this.top = (bounds.top > this.top) ? bounds.top 
-                                              : this.top;
-        }
     },
 
     /**



More information about the Commits mailing list