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

Commit 342ab1e

Browse files
committed
address review comments
1 parent 219c0f0 commit 342ab1e

File tree

5 files changed

+5
-47
lines changed

5 files changed

+5
-47
lines changed

src/auto/injector.js

+1-24
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,8 @@ var FN_ARG = /^\s*(_?)(\S+?)\1\s*$/;
7070
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
7171
var $injectorMinErr = minErr('$injector');
7272

73-
function stringifyFn(fn) {
74-
return Function.prototype.toString.call(fn);
75-
}
76-
7773
function extractArgs(fn) {
78-
var fnText = stringifyFn(fn).replace(STRIP_COMMENTS, ''),
74+
var fnText = Function.prototype.toString.call(fn).replace(STRIP_COMMENTS, ''),
7975
args = fnText.match(ARROW_ARG) || fnText.match(FN_ARGS);
8076
return args;
8177
}
@@ -914,19 +910,6 @@ function createInjector(modulesToLoad, strictDi) {
914910
return args;
915911
}
916912

917-
function isClass(func) {
918-
// Support: IE 9-11 only
919-
// IE 9-11 do not support classes and IE9 leaks with the code below.
920-
if (msie || typeof func !== 'function') {
921-
return false;
922-
}
923-
var result = func.$$ngIsClass;
924-
if (!isBoolean(result)) {
925-
result = func.$$ngIsClass = /^class\b/.test(stringifyFn(func));
926-
}
927-
return result;
928-
}
929-
930913
function invoke(fn, self, locals, serviceName) {
931914
if (typeof locals === 'string') {
932915
serviceName = locals;
@@ -938,12 +921,6 @@ function createInjector(modulesToLoad, strictDi) {
938921
fn = fn[fn.length - 1];
939922
}
940923

941-
if (isClass(fn)) {
942-
// This code path was used by $controller previously and is not really needed any more.
943-
args.unshift(null);
944-
return new (Function.prototype.bind.apply(fn, args))();
945-
}
946-
947924
// http://jsperf.com/angularjs-invoke-apply-vs-switch
948925
// #5388
949926
return fn.apply(self, args);

src/ng/compile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2819,7 +2819,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
28192819
controllerConstructor = attrs[name];
28202820
}
28212821

2822-
var instance = $controller(controllerConstructor, locals, false, directive.controllerAs);
2822+
var instance = $controller(controllerConstructor, locals, directive.controllerAs);
28232823

28242824
$element.data('$' + name + 'Controller', instance);
28252825

src/ng/controller.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,8 @@ function $ControllerProvider() {
8181
* It's just a simple call to {@link auto.$injector $injector}, but extracted into
8282
* a service, so that one can override this service with [BC version](https://gist.github.com/1649788).
8383
*/
84-
return function $controller(expression, locals, _ignored, ident) {
84+
return function $controller(expression, locals, ident) {
8585
// PRIVATE API:
86-
// param `_ignored` --- not used, kept for compatibility with the $controller decorator in ngMock
8786
// param `ident` --- An optional label which overrides the label parsed from the controller
8887
// expression, if any.
8988
var instance, match, constructor, identifier;

src/ngMock/angular-mocks.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2333,7 +2333,8 @@ angular.mock.$RootElementProvider = function() {
23332333
function createControllerDecorator() {
23342334
angular.mock.$ControllerDecorator = ['$delegate', function($delegate) {
23352335
return function(expression, locals, bindings, ident) {
2336-
var instance = $delegate(expression, locals, false, ident);
2336+
if (angular.isString(bindings)) ident = bindings;
2337+
var instance = $delegate(expression, locals, ident);
23372338
angular.extend(instance, bindings);
23382339
return instance;
23392340
};

test/auto/injectorSpec.js

-19
Original file line numberDiff line numberDiff line change
@@ -482,25 +482,6 @@ describe('injector', function() {
482482
expect(instance).toEqual(new Clazz('a-value'));
483483
expect(instance.aVal()).toEqual('a-value');
484484
});
485-
486-
they('should detect ES6 classes regardless of whitespace/comments ($prop)', [
487-
'class Test {}',
488-
'class Test{}',
489-
'class //<--ES6 stuff\nTest {}',
490-
'class//<--ES6 stuff\nTest {}',
491-
'class {}',
492-
'class{}',
493-
'class //<--ES6 stuff\n {}',
494-
'class//<--ES6 stuff\n {}',
495-
'class/* Test */{}',
496-
'class /* Test */ {}'
497-
], function(classDefinition) {
498-
// eslint-disable-next-line no-eval
499-
var Clazz = eval('(' + classDefinition + ')');
500-
var instance = injector.invoke(Clazz);
501-
502-
expect(instance).toEqual(jasmine.any(Clazz));
503-
});
504485
}
505486
});
506487

0 commit comments

Comments
 (0)