Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ function setupModuleLoader(window) {
* @description
* See {@link auto.$provide#decorator $provide.decorator()}.
*/
decorator: invokeLaterAndSetModuleName('$provide', 'decorator'),
decorator: invokeLaterAndSetModuleName('$provide', 'decorator', configBlocks),

/**
* @ngdoc method
Expand Down Expand Up @@ -349,10 +349,11 @@ function setupModuleLoader(window) {
* @param {string} method
* @returns {angular.Module}
*/
function invokeLaterAndSetModuleName(provider, method) {
function invokeLaterAndSetModuleName(provider, method, queue) {
if (!queue) queue = invokeQueue;
return function(recipeName, factoryFunction) {
if (factoryFunction && isFunction(factoryFunction)) factoryFunction.$$moduleName = name;
invokeQueue.push([provider, method, arguments]);
queue.push([provider, method, arguments]);
return moduleInstance;
};
}
Expand Down
13 changes: 12 additions & 1 deletion test/loaderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ describe('module loader', function() {
expect(myModule.requires).toEqual(['other']);
expect(myModule._invokeQueue).toEqual([
['$provide', 'constant', jasmine.objectContaining(['abc', 123])],
['$provide', 'decorator', jasmine.objectContaining(['dk', 'dv'])],
['$provide', 'provider', jasmine.objectContaining(['sk', 'sv'])],
['$provide', 'factory', jasmine.objectContaining(['fk', 'fv'])],
['$provide', 'service', jasmine.objectContaining(['a', 'aa'])],
Expand All @@ -60,12 +59,24 @@ describe('module loader', function() {
]);
expect(myModule._configBlocks).toEqual([
['$injector', 'invoke', jasmine.objectContaining(['config'])],
['$provide', 'decorator', jasmine.objectContaining(['dk', 'dv'])],
['$injector', 'invoke', jasmine.objectContaining(['init2'])]
]);
expect(myModule._runBlocks).toEqual(['runBlock']);
});


it("should not throw error when `module.decorator` is declared before provider that it decorates", function() {
angular.module('theModule', []).
decorator('theProvider', function($delegate) { return $delegate; }).
factory('theProvider', function() { return {}; });

expect(function() {
createInjector(['theModule']);
}).not.toThrow();
});


it('should allow module redefinition', function() {
expect(window.angular.module('a', [])).not.toBe(window.angular.module('a', []));
});
Expand Down