Author: johnh
Date: Thu Feb 10 01:55:14 2011
New Revision: 1069203

URL: http://svn.apache.org/viewvc?rev=1069203&view=rev
Log:
Allow update() before init(). Calls overwrite in emitted order.


Modified:
    
shindig/trunk/features/src/main/javascript/features/core.config.base/config.js
    shindig/trunk/features/src/test/javascript/features/core/config-test.js

Modified: 
shindig/trunk/features/src/main/javascript/features/core.config.base/config.js
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.config.base/config.js?rev=1069203&r1=1069202&r2=1069203&view=diff
==============================================================================
--- 
shindig/trunk/features/src/main/javascript/features/core.config.base/config.js 
(original)
+++ 
shindig/trunk/features/src/main/javascript/features/core.config.base/config.js 
Thu Feb 10 01:55:14 2011
@@ -262,7 +262,7 @@ gadgets.config = function() {
      * @param opt_replace {Boolean} true to replace all configuration.
      */
     'update': function(updateConfig, opt_replace) {
-      configuration = opt_replace ? {} : configuration;
+      configuration = opt_replace ? {} : configuration || {};
       foldConfig(configuration, updateConfig);
     }
   }

Modified: 
shindig/trunk/features/src/test/javascript/features/core/config-test.js
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/test/javascript/features/core/config-test.js?rev=1069203&r1=1069202&r2=1069203&view=diff
==============================================================================
--- shindig/trunk/features/src/test/javascript/features/core/config-test.js 
(original)
+++ shindig/trunk/features/src/test/javascript/features/core/config-test.js Thu 
Feb 10 01:55:14 2011
@@ -162,6 +162,23 @@ ConfigTest.prototype.testUpdateMerge = f
   this.assertEquals(123, testListen.three.foo);
 };
 
+ConfigTest.prototype.testUpdateBeforeInit = function() {
+  var testListen = null;
+  gadgets.config.register("one", null, function(config) {
+    testListen = config;
+  });
+  gadgets.config.update({
+    one: { oneKey1: { oneSubkey1: "oneVal1", sticks: "stones" }, breaks: 
"bones" }
+  });
+  this.assertTrue(testListen === null);
+  gadgets.config.init({
+    one: { oneKey1: { oneSubkey1: "overwrite" } }
+  });
+  this.assertEquals("overwrite", testListen.one.oneKey1.oneSubkey1);
+  this.assertEquals("stones", testListen.one.oneKey1.sticks);
+  this.assertEquals("bones", testListen.one.breaks);
+};
+
 ConfigTest.prototype.testMergeFromInlineConfig = function() {
   var testListen;
   gadgets.config.register("one", null, function(config) {


Reply via email to