You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by mm...@apache.org on 2013/02/25 14:40:50 UTC

[13/50] js commit: [all] Fix a corner case in modulemapper.

[all] Fix a corner case in modulemapper.

If the same symbol is clobbered twice, getOriginalSymbol should return
the first clobbered value.


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

Branch: refs/heads/multipart_plugin_result
Commit: 9de73d5f1067201ca96c1614ee881eb09f00e748
Parents: f47ecc0
Author: Andrew Grieve <ag...@chromium.org>
Authored: Sat Jan 26 10:01:44 2013 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Feb 12 14:24:33 2013 -0500

----------------------------------------------------------------------
 lib/common/modulemapper.js |    2 +-
 test/test.modulemapper.js  |    7 +++++++
 2 files changed, 8 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/9de73d5f/lib/common/modulemapper.js
----------------------------------------------------------------------
diff --git a/lib/common/modulemapper.js b/lib/common/modulemapper.js
index 7304f8f..bc414ca 100644
--- a/lib/common/modulemapper.js
+++ b/lib/common/modulemapper.js
@@ -82,7 +82,7 @@ exports.mapModules = function(context) {
         if (strategy == 'm' && target) {
             builder.recursiveMerge(target, module);
         } else if ((strategy == 'd' && !target) || (strategy != 'd')) {
-            if (target) {
+            if (!(symbolPath in origSymbols)) {
                 origSymbols[symbolPath] = target;
             }
             builder.assignOrWrapInDeprecateGetter(parentObj, lastName, module, deprecationMsg);

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/9de73d5f/test/test.modulemapper.js
----------------------------------------------------------------------
diff --git a/test/test.modulemapper.js b/test/test.modulemapper.js
index ccf3ed6..726b6eb 100644
--- a/test/test.modulemapper.js
+++ b/test/test.modulemapper.js
@@ -154,6 +154,13 @@ describe('modulemapper', function() {
         modulemapper.mapModules(context);
         expect(modulemapper.getOriginalSymbol(context, 'obj')).toBe(orig);
     });
+    it('should remember original symbols when double clobbering', function() {
+        var orig = context.obj;
+        modulemapper.clobbers('cordova/testmodule', 'obj');
+        modulemapper.clobbers('cordova/testmodule', 'obj');
+        modulemapper.mapModules(context);
+        expect(modulemapper.getOriginalSymbol(context, 'obj')).toBe(orig);
+    });
     it('should return original symbols when symbol was not clobbered', function() {
         modulemapper.mapModules(context);
         expect(modulemapper.getOriginalSymbol(context, 'obj')).toBe(context.obj);