aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Angular.js7
-rw-r--r--test/AngularSpec.js20
2 files changed, 27 insertions, 0 deletions
diff --git a/src/Angular.js b/src/Angular.js
index dbd662ce..16b31d4b 100644
--- a/src/Angular.js
+++ b/src/Angular.js
@@ -281,11 +281,18 @@ function inherit(parent, extra) {
function noop() {}
function identity($) {return $;}
function valueFn(value) {return function(){ return value; };}
+
function extensionMap(angular, name, transform) {
var extPoint;
return angular[name] || (extPoint = angular[name] = function (name, fn, prop){
name = (transform || identity)(name);
if (isDefined(fn)) {
+ if (isDefined(extPoint[name])) {
+ foreach(extPoint[name], function(property, key) {
+ if (key.charAt(0) == '$' && isUndefined(fn[key]))
+ fn[key] = property;
+ });
+ }
extPoint[name] = extend(fn, prop || {});
}
return extPoint[name];
diff --git a/test/AngularSpec.js b/test/AngularSpec.js
index bab7df18..d5005151 100644
--- a/test/AngularSpec.js
+++ b/test/AngularSpec.js
@@ -280,3 +280,23 @@ describe('angularJsConfig', function() {
ie_compat_id: 'ng-ie-compat'});
});
});
+
+describe('extensionMap', function() {
+ it('should preserve $ properties on override', function() {
+ var extension = extensionMap({}, 'fake');
+ extension('first', {$one: true, $two: true});
+ var result = extension('first', {$one: false, $three: true});
+
+ expect(result.$one).toBeFalsy();
+ expect(result.$two).toBeTruthy();
+ expect(result.$three).toBeTruthy();
+ });
+
+ it('should not preserve non-angular properties', function() {
+ var extension = extensionMap({}, 'fake');
+ extension('first', {two: true});
+ var result = extension('first', {$one: false, $three: true});
+
+ expect(result.two).not.toBeDefined();
+ });
+});