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

Commit bd58143

Browse files
committed
v1.7.2-build.5558+sha.c9a92fc
1 parent 6feaed7 commit bd58143

File tree

6 files changed

+486
-406
lines changed

6 files changed

+486
-406
lines changed

angular.js

Lines changed: 144 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license AngularJS v1.7.2-build.5557+sha.ad0ba99
2+
* @license AngularJS v1.7.2-build.5558+sha.c9a92fc
33
* (c) 2010-2018 Google, Inc. http://angularjs.org
44
* License: MIT
55
*/
@@ -99,7 +99,7 @@ function isValidObjectMaxDepth(maxDepth) {
9999
function minErr(module, ErrorConstructor) {
100100
ErrorConstructor = ErrorConstructor || Error;
101101

102-
var url = 'https://errors.angularjs.org/1.7.2-build.5557+sha.ad0ba99/';
102+
var url = 'https://errors.angularjs.org/1.7.2-build.5558+sha.c9a92fc/';
103103
var regex = url.replace('.', '\\.') + '[\\s\\S]*';
104104
var errRegExp = new RegExp(regex, 'g');
105105

@@ -2779,7 +2779,7 @@ function toDebugString(obj, maxDepth) {
27792779
var version = {
27802780
// These placeholder strings will be replaced by grunt's `build` task.
27812781
// They need to be double- or single-quoted.
2782-
full: '1.7.2-build.5557+sha.ad0ba99',
2782+
full: '1.7.2-build.5558+sha.c9a92fc',
27832783
major: 1,
27842784
minor: 7,
27852785
dot: 2,
@@ -2930,7 +2930,7 @@ function publishExternalAPI(angular) {
29302930
});
29312931
}
29322932
])
2933-
.info({ angularVersion: '1.7.2-build.5557+sha.ad0ba99' });
2933+
.info({ angularVersion: '1.7.2-build.5558+sha.c9a92fc' });
29342934
}
29352935

29362936
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
@@ -4234,8 +4234,12 @@ var FN_ARG = /^\s*(_?)(\S+?)\1\s*$/;
42344234
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
42354235
var $injectorMinErr = minErr('$injector');
42364236

4237+
function stringifyFn(fn) {
4238+
return Function.prototype.toString.call(fn);
4239+
}
4240+
42374241
function extractArgs(fn) {
4238-
var fnText = Function.prototype.toString.call(fn).replace(STRIP_COMMENTS, ''),
4242+
var fnText = stringifyFn(fn).replace(STRIP_COMMENTS, ''),
42394243
args = fnText.match(ARROW_ARG) || fnText.match(FN_ARGS);
42404244
return args;
42414245
}
@@ -5074,6 +5078,19 @@ function createInjector(modulesToLoad, strictDi) {
50745078
return args;
50755079
}
50765080

5081+
function isClass(func) {
5082+
// Support: IE 9-11 only
5083+
// IE 9-11 do not support classes and IE9 leaks with the code below.
5084+
if (msie || typeof func !== 'function') {
5085+
return false;
5086+
}
5087+
var result = func.$$ngIsClass;
5088+
if (!isBoolean(result)) {
5089+
result = func.$$ngIsClass = /^class\b/.test(stringifyFn(func));
5090+
}
5091+
return result;
5092+
}
5093+
50775094
function invoke(fn, self, locals, serviceName) {
50785095
if (typeof locals === 'string') {
50795096
serviceName = locals;
@@ -5085,9 +5102,14 @@ function createInjector(modulesToLoad, strictDi) {
50855102
fn = fn[fn.length - 1];
50865103
}
50875104

5088-
// http://jsperf.com/angularjs-invoke-apply-vs-switch
5089-
// #5388
5090-
return fn.apply(self, args);
5105+
if (!isClass(fn)) {
5106+
// http://jsperf.com/angularjs-invoke-apply-vs-switch
5107+
// #5388
5108+
return fn.apply(self, args);
5109+
} else {
5110+
args.unshift(null);
5111+
return new (Function.prototype.bind.apply(fn, args))();
5112+
}
50915113
}
50925114

50935115

@@ -9981,6 +10003,10 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
998110003
};
998210004
}
998310005

10006+
if (controllerDirectives) {
10007+
elementControllers = setupControllers($element, attrs, transcludeFn, controllerDirectives, isolateScope, scope, newIsolateScopeDirective);
10008+
}
10009+
998410010
if (newIsolateScopeDirective) {
998510011
// Initialize isolate scope bindings for new isolate scope directive.
998610012
compile.$$addScopeInfo($element, isolateScope, true, !(templateDirective && (templateDirective === newIsolateScopeDirective ||
@@ -9996,69 +10022,53 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
999610022
}
999710023
}
999810024

9999-
if (controllerDirectives) {
10000-
elementControllers = createMap();
10001-
for (var name in controllerDirectives) {
10002-
var directive = controllerDirectives[name];
10003-
var locals = {
10004-
$scope: directive === newIsolateScopeDirective || directive.$$isolateScope ? isolateScope : scope,
10005-
$element: $element,
10006-
$attrs: attrs,
10007-
$transclude: transcludeFn
10008-
};
10009-
10010-
var controllerConstructor = directive.controller;
10011-
if (controllerConstructor === '@') {
10012-
controllerConstructor = attrs[name];
10013-
}
10025+
// Initialize bindToController bindings
10026+
for (var name in elementControllers) {
10027+
var controllerDirective = controllerDirectives[name];
10028+
var controller = elementControllers[name];
10029+
var bindings = controllerDirective.$$bindings.bindToController;
1001410030

10015-
var instance = $controller(controllerConstructor, locals, directive.controllerAs);
10016-
10017-
$element.data('$' + name + 'Controller', instance);
10018-
10019-
// Initialize bindToController bindings
10020-
var bindings = directive.$$bindings.bindToController;
10021-
var bindingInfo = initializeDirectiveBindings(controllerScope, attrs, instance, bindings, directive);
10022-
10023-
elementControllers[name] = { instance: instance, bindingInfo: bindingInfo };
10031+
controller.instance = controller();
10032+
$element.data('$' + controllerDirective.name + 'Controller', controller.instance);
10033+
controller.bindingInfo =
10034+
initializeDirectiveBindings(controllerScope, attrs, controller.instance, bindings, controllerDirective);
1002410035
}
1002510036

10026-
// Bind the required controllers to the controller, if `require` is an object and `bindToController` is truthy
10027-
forEach(controllerDirectives, function(controllerDirective, name) {
10028-
var require = controllerDirective.require;
10029-
if (controllerDirective.bindToController && !isArray(require) && isObject(require)) {
10030-
extend(elementControllers[name].instance, getControllers(name, require, $element, elementControllers));
10031-
}
10032-
});
10037+
// Bind the required controllers to the controller, if `require` is an object and `bindToController` is truthy
10038+
forEach(controllerDirectives, function(controllerDirective, name) {
10039+
var require = controllerDirective.require;
10040+
if (controllerDirective.bindToController && !isArray(require) && isObject(require)) {
10041+
extend(elementControllers[name].instance, getControllers(name, require, $element, elementControllers));
10042+
}
10043+
});
1003310044

10034-
// Handle the init and destroy lifecycle hooks on all controllers that have them
10035-
forEach(elementControllers, function(controller) {
10036-
var controllerInstance = controller.instance;
10037-
if (isFunction(controllerInstance.$onChanges)) {
10038-
try {
10039-
controllerInstance.$onChanges(controller.bindingInfo.initialChanges);
10040-
} catch (e) {
10041-
$exceptionHandler(e);
10042-
}
10043-
}
10044-
if (isFunction(controllerInstance.$onInit)) {
10045-
try {
10046-
controllerInstance.$onInit();
10047-
} catch (e) {
10048-
$exceptionHandler(e);
10049-
}
10050-
}
10051-
if (isFunction(controllerInstance.$doCheck)) {
10052-
controllerScope.$watch(function() { controllerInstance.$doCheck(); });
10053-
controllerInstance.$doCheck();
10045+
// Handle the init and destroy lifecycle hooks on all controllers that have them
10046+
forEach(elementControllers, function(controller) {
10047+
var controllerInstance = controller.instance;
10048+
if (isFunction(controllerInstance.$onChanges)) {
10049+
try {
10050+
controllerInstance.$onChanges(controller.bindingInfo.initialChanges);
10051+
} catch (e) {
10052+
$exceptionHandler(e);
1005410053
}
10055-
if (isFunction(controllerInstance.$onDestroy)) {
10056-
controllerScope.$on('$destroy', function callOnDestroyHook() {
10057-
controllerInstance.$onDestroy();
10058-
});
10054+
}
10055+
if (isFunction(controllerInstance.$onInit)) {
10056+
try {
10057+
controllerInstance.$onInit();
10058+
} catch (e) {
10059+
$exceptionHandler(e);
1005910060
}
10060-
});
10061-
}
10061+
}
10062+
if (isFunction(controllerInstance.$doCheck)) {
10063+
controllerScope.$watch(function() { controllerInstance.$doCheck(); });
10064+
controllerInstance.$doCheck();
10065+
}
10066+
if (isFunction(controllerInstance.$onDestroy)) {
10067+
controllerScope.$on('$destroy', function callOnDestroyHook() {
10068+
controllerInstance.$onDestroy();
10069+
});
10070+
}
10071+
});
1006210072

1006310073
// PRELINKING
1006410074
for (i = 0, ii = preLinkFns.length; i < ii; i++) {
@@ -10186,6 +10196,34 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
1018610196
return value || null;
1018710197
}
1018810198

10199+
function setupControllers($element, attrs, transcludeFn, controllerDirectives, isolateScope, scope, newIsolateScopeDirective) {
10200+
var elementControllers = createMap();
10201+
for (var controllerKey in controllerDirectives) {
10202+
var directive = controllerDirectives[controllerKey];
10203+
var locals = {
10204+
$scope: directive === newIsolateScopeDirective || directive.$$isolateScope ? isolateScope : scope,
10205+
$element: $element,
10206+
$attrs: attrs,
10207+
$transclude: transcludeFn
10208+
};
10209+
10210+
var controller = directive.controller;
10211+
if (controller === '@') {
10212+
controller = attrs[directive.name];
10213+
}
10214+
10215+
var controllerInstance = $controller(controller, locals, true, directive.controllerAs);
10216+
10217+
// For directives with element transclusion the element is a comment.
10218+
// In this case .data will not attach any data.
10219+
// Instead, we save the controllers for the element in a local hash and attach to .data
10220+
// later, once we have the actual element.
10221+
elementControllers[directive.name] = controllerInstance;
10222+
$element.data('$' + directive.name + 'Controller', controllerInstance.instance);
10223+
}
10224+
return elementControllers;
10225+
}
10226+
1018910227
// Depending upon the context in which a directive finds itself it might need to have a new isolated
1019010228
// or child scope created. For instance:
1019110229
// * if the directive has been pulled into a template because another directive with a higher priority
@@ -11064,11 +11102,16 @@ function $ControllerProvider() {
1106411102
* It's just a simple call to {@link auto.$injector $injector}, but extracted into
1106511103
* a service, so that one can override this service with [BC version](https://gist.github.com/1649788).
1106611104
*/
11067-
return function $controller(expression, locals, ident) {
11105+
return function $controller(expression, locals, later, ident) {
1106811106
// PRIVATE API:
11107+
// param `later` --- indicates that the controller's constructor is invoked at a later time.
11108+
// If true, $controller will allocate the object with the correct
11109+
// prototype chain, but will not invoke the controller until a returned
11110+
// callback is invoked.
1106911111
// param `ident` --- An optional label which overrides the label parsed from the controller
1107011112
// expression, if any.
1107111113
var instance, match, constructor, identifier;
11114+
later = later === true;
1107211115
if (ident && isString(ident)) {
1107311116
identifier = ident;
1107411117
}
@@ -11094,6 +11137,41 @@ function $ControllerProvider() {
1109411137
assertArgFn(expression, constructor, true);
1109511138
}
1109611139

11140+
if (later) {
11141+
// Instantiate controller later:
11142+
// This machinery is used to create an instance of the object before calling the
11143+
// controller's constructor itself.
11144+
//
11145+
// This allows properties to be added to the controller before the constructor is
11146+
// invoked. Primarily, this is used for isolate scope bindings in $compile.
11147+
//
11148+
// This feature is not intended for use by applications, and is thus not documented
11149+
// publicly.
11150+
// Object creation: http://jsperf.com/create-constructor/2
11151+
var controllerPrototype = (isArray(expression) ?
11152+
expression[expression.length - 1] : expression).prototype;
11153+
instance = Object.create(controllerPrototype || null);
11154+
11155+
if (identifier) {
11156+
addIdentifier(locals, identifier, instance, constructor || expression.name);
11157+
}
11158+
11159+
return extend(function $controllerInit() {
11160+
var result = $injector.invoke(expression, instance, locals, constructor);
11161+
if (result !== instance && (isObject(result) || isFunction(result))) {
11162+
instance = result;
11163+
if (identifier) {
11164+
// If result changed, re-assign controllerAs value to scope.
11165+
addIdentifier(locals, identifier, instance, constructor || expression.name);
11166+
}
11167+
}
11168+
return instance;
11169+
}, {
11170+
instance: instance,
11171+
identifier: identifier
11172+
});
11173+
}
11174+
1109711175
instance = $injector.instantiate(expression, locals, constructor);
1109811176

1109911177
if (identifier) {

0 commit comments

Comments
 (0)