Skip to content
Permalink
Browse files

fix($injector): Allows ES6 function syntax

Closes #12424
Closes #12425
  • Loading branch information
lgalfaso committed Jul 23, 2015
1 parent 1cf10ab commit 44a96a4c140873d9fd8484d870af83a0bb9acabd
Showing with 10 additions and 1 deletion.
  1. +1 −1 src/auto/injector.js
  2. +9 −0 test/auto/injectorSpec.js
@@ -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;
@@ -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();

0 comments on commit 44a96a4

Please sign in to comment.
You can’t perform that action at this time.