Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 44a96a4

Browse files
committed
fix($injector): Allows ES6 function syntax
Closes #12424 Closes #12425
1 parent 1cf10ab commit 44a96a4

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/auto/injector.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
* Implicit module which gets automatically added to each {@link auto.$injector $injector}.
6363
*/
6464

65-
var FN_ARGS = /^function\s*[^\(]*\(\s*([^\)]*)\)/m;
65+
var FN_ARGS = /^[^\(]*\(\s*([^\)]*)\)/m;
6666
var FN_ARG_SPLIT = /,/;
6767
var FN_ARG = /^\s*(_?)(\S+?)\1\s*$/;
6868
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;

test/auto/injectorSpec.js

+9
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,15 @@ describe('injector', function() {
243243
});
244244

245245

246+
// Only Chrome and Firefox support this syntax.
247+
if (/chrome|firefox/i.test(navigator.userAgent)) {
248+
it('should be possible to annotate functions that are declared using ES6 syntax', function() {
249+
// The function is generated using `eval` as just having the ES6 syntax can break some browsers.
250+
expect(annotate(eval('({ fn(x) { return; } })').fn)).toEqual(['x']);
251+
});
252+
}
253+
254+
246255
it('should publish annotate API', function() {
247256
expect(angular.mock.$$annotate).toBe(annotate);
248257
spyOn(angular.mock, '$$annotate').andCallThrough();

0 commit comments

Comments
 (0)