Skip to content

Commit 2e0441d

Browse files
committed
refactor($injector): minor clean up
1 parent ab325a0 commit 2e0441d

File tree

2 files changed

+24
-25
lines changed

2 files changed

+24
-25
lines changed

src/auto/injector.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function stringifyFn(fn) {
7474
// Support: Chrome 50-51 only
7575
// Creating a new string by adding `' '` at the end, to hack around some bug in Chrome v50/51
7676
// (See https://github.com/angular/angular.js/issues/14487.)
77-
// TODO (gkalpak): Remove workaround when Chrome v52 is released
77+
// TODO(gkalpak): Remove workaround when Chrome v52 is released
7878
return Function.prototype.toString.call(fn) + ' ';
7979
}
8080

@@ -649,16 +649,16 @@ function createInjector(modulesToLoad, strictDi) {
649649
var INSTANTIATING = {},
650650
providerSuffix = 'Provider',
651651
path = [],
652-
loadedModules = new HashMap([], true),
652+
loadedModules = new HashMap(null, true),
653653
providerCache = {
654654
$provide: {
655-
provider: supportObject(provider),
656-
factory: supportObject(factory),
657-
service: supportObject(service),
658-
value: supportObject(value),
659-
constant: supportObject(constant),
660-
decorator: decorator
661-
}
655+
provider: supportObject(provider),
656+
factory: supportObject(factory),
657+
service: supportObject(service),
658+
value: supportObject(value),
659+
constant: supportObject(constant),
660+
decorator: decorator
661+
}
662662
},
663663
providerInjector = (providerCache.$injector =
664664
createInternalInjector(providerCache, function(serviceName, caller) {
@@ -731,7 +731,9 @@ function createInjector(modulesToLoad, strictDi) {
731731
}]);
732732
}
733733

734-
function value(name, val) { return factory(name, valueFn(val), false); }
734+
function value(name, val) {
735+
return factory(name, valueFn(val), false);
736+
}
735737

736738
function constant(name, value) {
737739
assertNotHasOwnProperty(name, 'constant');
@@ -775,9 +777,7 @@ function createInjector(modulesToLoad, strictDi) {
775777
runBlocks = runBlocks.concat(loadModules(moduleFn.requires)).concat(moduleFn._runBlocks);
776778
runInvokeQueue(moduleFn._invokeQueue);
777779
runInvokeQueue(moduleFn._configBlocks);
778-
} else if (isFunction(module)) {
779-
runBlocks.push(providerInjector.invoke(module));
780-
} else if (isArray(module)) {
780+
} else if (isFunction(module) || isArray(module)) {
781781
runBlocks.push(providerInjector.invoke(module));
782782
} else {
783783
assertArgFn(module, 'module');

test/auto/injectorSpec.js

+11-12
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ describe('injector', function() {
4646
it('should resolve dependency graph and instantiate all services just once', function() {
4747
var log = [];
4848

49-
// s1
50-
// / | \
51-
// / s2 \
52-
// / / | \ \
53-
// /s3 < s4 > s5
54-
// //
55-
// s6
49+
// ____ s1 _
50+
// / | \
51+
// / __ s2 __ \
52+
// / / | \ \
53+
// | s3 <- s4 --> s5
54+
// | /
55+
// s6
5656

5757

5858
providers('s1', function() { log.push('s1'); return {}; }, {$inject: ['s2', 's5', 's6']});
@@ -287,7 +287,7 @@ describe('injector', function() {
287287
});
288288

289289
// Support: Chrome 50-51 only
290-
// TODO (gkalpak): Remove when Chrome v52 is released.
290+
// TODO(gkalpak): Remove when Chrome v52 is released.
291291
// it('should be able to inject fat-arrow function', function() {
292292
// inject(($injector) => {
293293
// expect($injector).toBeDefined();
@@ -327,7 +327,7 @@ describe('injector', function() {
327327
}
328328

329329
// Support: Chrome 50-51 only
330-
// TODO (gkalpak): Remove when Chrome v52 is released.
330+
// TODO(gkalpak): Remove when Chrome v52 is released.
331331
// it('should be able to invoke classes', function() {
332332
// class Test {
333333
// constructor($injector) {
@@ -884,7 +884,6 @@ describe('injector', function() {
884884
var $injector = createInjectorWithValue('instance', instance);
885885
expect($injector.invoke(function(instance) { return instance; })).toBe(instance);
886886
});
887-
888887
});
889888

890889

@@ -1039,7 +1038,7 @@ describe('injector', function() {
10391038

10401039
describe('protection modes', function() {
10411040
it('should prevent provider lookup in app', function() {
1042-
var $injector = createInjector([function($provide) {
1041+
var $injector = createInjector([function($provide) {
10431042
$provide.value('name', 'angular');
10441043
}]);
10451044
expect(function() {
@@ -1049,7 +1048,7 @@ describe('injector', function() {
10491048

10501049

10511050
it('should prevent provider configuration in app', function() {
1052-
var $injector = createInjector([]);
1051+
var $injector = createInjector([]);
10531052
expect(function() {
10541053
$injector.get('$provide').value('a', 'b');
10551054
}).toThrowMinErr("$injector", "unpr", "Unknown provider: $provideProvider <- $provide");

0 commit comments

Comments
 (0)