@@ -821,17 +821,6 @@ function createInjector(modulesToLoad, strictDi) {
821821 return args ;
822822 }
823823
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-
835824 function invoke ( fn , self , locals , serviceName ) {
836825 if ( typeof locals === 'string' ) {
837826 serviceName = locals ;
@@ -843,15 +832,12 @@ function createInjector(modulesToLoad, strictDi) {
843832 fn = fn [ fn . length - 1 ] ;
844833 }
845834
846- if ( ! isClass ( fn ) ) {
835+ try {
847836 // http://jsperf.com/angularjs-invoke-apply-vs-switch
848- // #5388
849837 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 ) ) ) ( ) ;
855841 }
856842 }
857843
@@ -863,9 +849,7 @@ function createInjector(modulesToLoad, strictDi) {
863849 var args = injectionArgs ( Type , locals , serviceName ) ;
864850 // Empty object at position 0 is ignored for invocation with `new`, but required.
865851 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 ) ) ( ) ;
869853 }
870854
871855
0 commit comments