cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [1/24] js commit: [all] Fix modulemapper for nested namespaces.
Date Tue, 12 Feb 2013 19:32:42 GMT
[all] Fix modulemapper for nested namespaces.


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/6fbcdc89
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/6fbcdc89
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/6fbcdc89

Branch: refs/heads/master
Commit: 6fbcdc891f632b12ef914d9f5a9ad0aba53dbc19
Parents: 377be7a
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Tue Feb 12 13:43:43 2013 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Tue Feb 12 13:44:21 2013 -0500

----------------------------------------------------------------------
 lib/common/modulemapper.js |    4 ++--
 test/test.modulemapper.js  |    9 +++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6fbcdc89/lib/common/modulemapper.js
----------------------------------------------------------------------
diff --git a/lib/common/modulemapper.js b/lib/common/modulemapper.js
index ab20588..7304f8f 100644
--- a/lib/common/modulemapper.js
+++ b/lib/common/modulemapper.js
@@ -58,9 +58,9 @@ function prepareNamespace(symbolPath, context) {
     var parts = symbolPath.split('.');
     var cur = context;
     for (var i = 0, part; part = parts[i]; ++i) {
-        cur[part] = cur[part] || {};
+        cur = cur[part] = cur[part] || {};
     }
-    return cur[parts[i-1]];
+    return cur;
 }
 
 exports.mapModules = function(context) {

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6fbcdc89/test/test.modulemapper.js
----------------------------------------------------------------------
diff --git a/test/test.modulemapper.js b/test/test.modulemapper.js
index bc73042..ccf3ed6 100644
--- a/test/test.modulemapper.js
+++ b/test/test.modulemapper.js
@@ -62,6 +62,15 @@ describe('modulemapper', function() {
         expect(context.foo2.newProp).toBe(testmodule);
         expect(context.foo3.newProp).toBe(testmodule);
     });
+    it('should properly set a new non-top-level property #2', function() {
+        modulemapper.clobbers('cordova/testmodule', 'foo1.bar.newProp');
+        modulemapper.defaults('cordova/testmodule', 'foo2.bar.newProp');
+        modulemapper.merges('cordova/testmodule', 'foo3.bar.newProp');
+        modulemapper.mapModules(context);
+        expect(context.foo1.bar.newProp).toBe(testmodule);
+        expect(context.foo2.bar.newProp).toBe(testmodule);
+        expect(context.foo3.bar.newProp).toBe(testmodule);
+    });
     it('should properly set a non-new non-top-level property', function() {
         modulemapper.clobbers('cordova/testmodule', 'obj.newProp1');
         modulemapper.defaults('cordova/testmodule', 'obj.newProp2');


Mime
View raw message