Skip to content

Commit b3e3365

Browse files
committed
Match directive controllers in arrow expressions with an expression body.
1 parent 24d3ed4 commit b3e3365

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

babel-ng-annotate.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ module.exports = function() {
106106
ArrowFunctionExpression: {
107107
enter(path) {
108108
ngInject.inspectFunction(path, ctx);
109+
},
110+
exit(path, state) {
111+
if(!state.opts.explicitOnly){
112+
let targets = matchDirectiveReturnObject(path);
113+
addTargets(targets);
114+
}
109115
}
110116
},
111117
FunctionDeclaration: {

ng-annotate-main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ function matchDirectiveReturnObject(path) {
7373
// only matches inside directives
7474
// return { .. controller: function($scope, $timeout), ...}
7575

76-
return limit("directive", t.isReturnStatement(node) &&
77-
node.argument && t.isObjectExpression(node.argument) &&
78-
matchProp("controller", (path.get && path.get("argument.properties") || node.argument.properties)));
76+
return limit("directive",
77+
(t.isReturnStatement(node) && node.argument && t.isObjectExpression(node.argument) && matchProp("controller", (path.get && path.get("argument.properties") || node.argument.properties))) ||
78+
(t.isArrowFunctionExpression(node) && node.body && t.isObjectExpression(node.body) && matchProp("controller", (path.get && path.get("body.properties") || node.body.properties))));
7979
}
8080

8181
function limit(name, path) {

0 commit comments

Comments
 (0)