File tree 2 files changed +28
-3
lines changed
2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -70,12 +70,16 @@ var FN_ARG = /^\s*(_?)(\S+?)\1\s*$/;
70
70
var STRIP_COMMENTS = / ( ( \/ \/ .* $ ) | ( \/ \* [ \s \S ] * ?\* \/ ) ) / mg;
71
71
var $injectorMinErr = minErr ( '$injector' ) ;
72
72
73
- function extractArgs ( fn ) {
73
+ function stringifyFn ( fn ) {
74
74
// Support: Chrome 50-51 only
75
75
// Creating a new string by adding `' '` at the end, to hack around some bug in Chrome v50/51
76
76
// (See https://github.com/angular/angular.js/issues/14487.)
77
77
// TODO (gkalpak): Remove workaround when Chrome v52 is released
78
- var fnText = Function . prototype . toString . call ( fn ) . replace ( STRIP_COMMENTS , '' ) + ' ' ,
78
+ return Function . prototype . toString . call ( fn ) + ' ' ;
79
+ }
80
+
81
+ function extractArgs ( fn ) {
82
+ var fnText = stringifyFn ( fn ) . replace ( STRIP_COMMENTS , '' ) ,
79
83
args = fnText . match ( ARROW_ARG ) || fnText . match ( FN_ARGS ) ;
80
84
return args ;
81
85
}
@@ -849,7 +853,7 @@ function createInjector(modulesToLoad, strictDi) {
849
853
if ( ! isBoolean ( result ) ) {
850
854
// Workaround for MS Edge.
851
855
// Check https://connect.microsoft.com/IE/Feedback/Details/2211653
852
- result = func . $$ngIsClass = / ^ (?: c l a s s \s | c o n s t r u c t o r \( ) / . test ( Function . prototype . toString . call ( func ) ) ;
856
+ result = func . $$ngIsClass = / ^ (?: c l a s s \s | c o n s t r u c t o r \( ) / . test ( stringifyFn ( func ) ) ;
853
857
}
854
858
return result ;
855
859
}
Original file line number Diff line number Diff line change @@ -283,6 +283,14 @@ describe('injector', function() {
283
283
it ( 'should take args before first arrow' , function ( ) {
284
284
expect ( annotate ( eval ( 'a => b => b' ) ) ) . toEqual ( [ 'a' ] ) ;
285
285
} ) ;
286
+
287
+ // Support: Chrome 50-51 only
288
+ // TODO (gkalpak): Remove when Chrome v52 is relased.
289
+ // it('should be able to inject fat-arrow function', function() {
290
+ // inject(($injector) => {
291
+ // expect($injector).toBeDefined();
292
+ // });
293
+ // });
286
294
}
287
295
288
296
if ( support . classes ) {
@@ -293,6 +301,19 @@ describe('injector', function() {
293
301
expect ( instance ) . toEqual ( new Clazz ( 'a-value' ) ) ;
294
302
expect ( instance . aVal ( ) ) . toEqual ( 'a-value' ) ;
295
303
} ) ;
304
+
305
+ // Support: Chrome 50-51 only
306
+ // TODO (gkalpak): Remove when Chrome v52 is relased.
307
+ // it('should be able to invoke classes', function() {
308
+ // class Test {
309
+ // constructor($injector) {
310
+ // this.$injector = $injector;
311
+ // }
312
+ // }
313
+ // var instance = injector.invoke(Test, null, null, 'Test');
314
+
315
+ // expect(instance.$injector).toBe(injector);
316
+ // });
296
317
}
297
318
/*jshint +W061 */
298
319
} ) ;
You can’t perform that action at this time.
0 commit comments