Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
fix($injector): Allows ES6 function syntax
Closes #12424
Closes #12425
  • Loading branch information
lgalfaso committed Aug 9, 2015
1 parent 1cf10ab commit 44a96a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/auto/injector.js
Expand Up @@ -62,7 +62,7 @@
* Implicit module which gets automatically added to each {@link auto.$injector $injector}.
*/

var FN_ARGS = /^function\s*[^\(]*\(\s*([^\)]*)\)/m;
var FN_ARGS = /^[^\(]*\(\s*([^\)]*)\)/m;
var FN_ARG_SPLIT = /,/;
var FN_ARG = /^\s*(_?)(\S+?)\1\s*$/;
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
Expand Down
9 changes: 9 additions & 0 deletions test/auto/injectorSpec.js
Expand Up @@ -243,6 +243,15 @@ describe('injector', function() {
});


// Only Chrome and Firefox support this syntax.
if (/chrome|firefox/i.test(navigator.userAgent)) {
it('should be possible to annotate functions that are declared using ES6 syntax', function() {
// The function is generated using `eval` as just having the ES6 syntax can break some browsers.
expect(annotate(eval('({ fn(x) { return; } })').fn)).toEqual(['x']);
});
}


it('should publish annotate API', function() {
expect(angular.mock.$$annotate).toBe(annotate);
spyOn(angular.mock, '$$annotate').andCallThrough();
Expand Down

0 comments on commit 44a96a4

Please sign in to comment.