Revert "Issue #51: Update extensionMap()"

This reverts commit 00ca67e4be.

Now that we don't have published services, we don't need to worryi
about this any more and in fact this behavior is confusing because
to override a service that has dependencies with a services with
no dependencies one must specify $inject:[] or else the old
dependencies will be injected.

Conflicts:

	src/Angular.js
	test/AngularSpec.js
This commit is contained in:
Igor Minar 2011-01-06 11:50:24 -08:00
parent bd5ec7c32a
commit 142a985f33
2 changed files with 7 additions and 32 deletions

View file

@ -253,18 +253,11 @@ 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];

View file

@ -284,25 +284,6 @@ describe('angularJsConfig', function() {
});
});
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();
});
});
describe('angular service', function() {
it('should override services', function() {
@ -313,13 +294,14 @@ describe('angular service', function() {
expect(scope.$service('fake')).toEqual('new');
});
it('should preserve $ properties on override', function() {
angular.service('fake', {$one: true}, {$two: true});
var result = angular.service('fake', {$third: true});
it('should not preserve properties on override', function() {
angular.service('fake', {$one: true}, {$two: true}, {three: true});
var result = angular.service('fake', {$four: true});
expect(result.$one).toBeTruthy();
expect(result.$two).toBeTruthy();
expect(result.$third).toBeTruthy();
expect(result.$one).toBeUndefined();
expect(result.$two).toBeUndefined();
expect(result.three).toBeUndefined();
expect(result.$four).toBe(true);
});
it('should not preserve non-angular properties on override', function() {