Permalink
Browse files

[all] Fix a corner case in modulemapper.

If the same symbol is clobbered twice, getOriginalSymbol should return
the first clobbered value.
  • Loading branch information...
1 parent f47ecc0 commit 9de73d5f1067201ca96c1614ee881eb09f00e748 @agrieve agrieve committed Jan 26, 2013
Showing with 8 additions and 1 deletion.
  1. +1 −1 lib/common/modulemapper.js
  2. +7 −0 test/test.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);
@@ -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);

0 comments on commit 9de73d5

Please sign in to comment.