mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
fix($injector): properly infer dependencies from fn with no args
Previously if there was a white-space in fn: fn( ) {} we failed to infer no args.
This was originally reported by recht, but I decided to use a different fix.
Closes #829
This commit is contained in:
parent
2f2fd465a4
commit
2cb907a836
2 changed files with 8 additions and 1 deletions
|
|
@ -38,7 +38,7 @@
|
|||
* Implicit module which gets automatically added to each {@link angular.module.AUTO.$injector $injector}.
|
||||
*/
|
||||
|
||||
var FN_ARGS = /^function\s*[^\(]*\(([^\)]*)\)/m;
|
||||
var FN_ARGS = /^function\s*[^\(]*\(\s*([^\)]*)\)/m;
|
||||
var FN_ARG_SPLIT = /,/;
|
||||
var FN_ARG = /^\s*(_?)(.+?)\1\s*$/;
|
||||
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
|
||||
|
|
|
|||
|
|
@ -160,6 +160,13 @@ describe('injector', function() {
|
|||
});
|
||||
|
||||
|
||||
it('should handle no arg functions with spaces in the arguments list', function() {
|
||||
function fn( ) {}
|
||||
expect(inferInjectionArgs(fn)).toEqual([]);
|
||||
expect(fn.$inject).toEqual([]);
|
||||
});
|
||||
|
||||
|
||||
it('should handle args with both $ and _', function() {
|
||||
function $f_n0($a_) {}
|
||||
expect(inferInjectionArgs($f_n0)).toEqual(['$a_']);
|
||||
|
|
|
|||
Loading…
Reference in a new issue