mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-27 11:40:27 +00:00
fix($injector): don't parse fns with no args
When annotating a fn, it is wasteful to try to parse a fn that has no arguments as such fn has no injectable dependencies
This commit is contained in:
parent
35d4993c3d
commit
44b6b72e5e
1 changed files with 8 additions and 6 deletions
|
|
@ -52,13 +52,15 @@ function annotate(fn) {
|
|||
if (typeof fn == 'function') {
|
||||
if (!($inject = fn.$inject)) {
|
||||
$inject = [];
|
||||
fnText = fn.toString().replace(STRIP_COMMENTS, '');
|
||||
argDecl = fnText.match(FN_ARGS);
|
||||
forEach(argDecl[1].split(FN_ARG_SPLIT), function(arg){
|
||||
arg.replace(FN_ARG, function(all, underscore, name){
|
||||
$inject.push(name);
|
||||
if (fn.length) {
|
||||
fnText = fn.toString().replace(STRIP_COMMENTS, '');
|
||||
argDecl = fnText.match(FN_ARGS);
|
||||
forEach(argDecl[1].split(FN_ARG_SPLIT), function(arg){
|
||||
arg.replace(FN_ARG, function(all, underscore, name){
|
||||
$inject.push(name);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
fn.$inject = $inject;
|
||||
}
|
||||
} else if (isArray(fn)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue