@@ -821,17 +821,6 @@ function createInjector(modulesToLoad, strictDi) {
821
821
return args ;
822
822
}
823
823
824
- function isClass ( func ) {
825
- // IE 9-11 do not support classes and IE9 leaks with the code below.
826
- if ( msie <= 11 ) {
827
- return false ;
828
- }
829
- // Workaround for MS Edge.
830
- // Check https://connect.microsoft.com/IE/Feedback/Details/2211653
831
- return typeof func === 'function'
832
- && / ^ (?: c l a s s \s | c o n s t r u c t o r \( ) / . test ( Function . prototype . toString . call ( func ) ) ;
833
- }
834
-
835
824
function invoke ( fn , self , locals , serviceName ) {
836
825
if ( typeof locals === 'string' ) {
837
826
serviceName = locals ;
@@ -843,15 +832,12 @@ function createInjector(modulesToLoad, strictDi) {
843
832
fn = fn [ fn . length - 1 ] ;
844
833
}
845
834
846
- if ( ! isClass ( fn ) ) {
835
+ try {
847
836
// http://jsperf.com/angularjs-invoke-apply-vs-switch
848
- // #5388
849
837
return fn . apply ( self , args ) ;
850
- } else {
851
- args . unshift ( null ) ;
852
- /*jshint -W058 */ // Applying a constructor without immediate parentheses is the point here.
853
- return new ( Function . prototype . bind . apply ( fn , args ) ) ;
854
- /*jshint +W058 */
838
+ } catch ( e ) {
839
+ // if `fn` is a class, then it needs to be called using `new`
840
+ return new ( Function . prototype . bind . apply ( fn , [ null ] . concat ( args ) ) ) ( ) ;
855
841
}
856
842
}
857
843
@@ -863,9 +849,7 @@ function createInjector(modulesToLoad, strictDi) {
863
849
var args = injectionArgs ( Type , locals , serviceName ) ;
864
850
// Empty object at position 0 is ignored for invocation with `new`, but required.
865
851
args . unshift ( null ) ;
866
- /*jshint -W058 */ // Applying a constructor without immediate parentheses is the point here.
867
- return new ( Function . prototype . bind . apply ( ctor , args ) ) ;
868
- /*jshint +W058 */
852
+ return new ( Function . prototype . bind . apply ( ctor , args ) ) ( ) ;
869
853
}
870
854
871
855
0 commit comments