[OpenLayers-Commits] r5162 - in trunk/openlayers: lib/OpenLayers tests

commits at openlayers.org commits at openlayers.org
Fri Nov 9 15:13:32 EST 2007


Author: elemoine
Date: 2007-11-09 15:13:31 -0500 (Fri, 09 Nov 2007)
New Revision: 5162

Modified:
   trunk/openlayers/lib/OpenLayers/Util.js
   trunk/openlayers/tests/test_Util.html
Log:
Make OpenLayers.Util.applyDefaults() return the modified object. To be consistent with OpenLayers.Util.Extend() and be able to use anonymous object as the 'to' object. Thanks fredj for the patch and tests. Thanks euzuro and crschmidt for the reviews. (closes #992)


Modified: trunk/openlayers/lib/OpenLayers/Util.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Util.js	2007-11-09 18:50:06 UTC (rev 5161)
+++ trunk/openlayers/lib/OpenLayers/Util.js	2007-11-09 20:13:31 UTC (rev 5162)
@@ -503,6 +503,7 @@
             to[key] = from[key];
         }
     }
+    return to;
 };
 
 /**

Modified: trunk/openlayers/tests/test_Util.html
===================================================================
--- trunk/openlayers/tests/test_Util.html	2007-11-09 18:50:06 UTC (rev 5161)
+++ trunk/openlayers/tests/test_Util.html	2007-11-09 20:13:31 UTC (rev 5162)
@@ -143,7 +143,7 @@
 
     function test_06_Util_applyDefaults(t) {
     
-        t.plan(4);
+        t.plan(8);
         
         var to = { 
             'a': "abra",
@@ -161,6 +161,12 @@
         t.eq( to["a"], "abra", "key present in to but not from maintained");
         t.eq( to["b"], "blorg", "key present in to and from, maintained in to");
         t.eq( to["c"], "press", "key present in from and not to successfully copied to to");
+
+        var ret = OpenLayers.Util.applyDefaults({'a': "abra",'b': "blorg"}, from);
+        t.ok( ret instanceof Object, " applyDefaults returns an object");
+        t.eq( ret["a"], "abra", "key present in ret but not from maintained");
+        t.eq( ret["b"], "blorg", "key present in ret and from, maintained in ret");
+        t.eq( ret["c"], "press", "key present in from and not ret successfully copied to ret");
     }
 
     function test_07_Util_getParameterString(t) {



More information about the Commits mailing list