@angular-wave/angular.ts 0.0.62 → 0.0.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Makefile +6 -2
- package/dist/angular-ts.esm.js +2 -2
- package/dist/angular-ts.umd.js +2 -2
- package/package.json +1 -1
- package/src/angular.spec.js +13 -27
- package/src/animations/animate-css-driver.js +1 -1
- package/src/animations/animate-queue.js +9 -0
- package/src/animations/module.js +2 -2
- package/src/binding.spec.js +6 -3
- package/src/core/animate/animate.spec.js +1 -3
- package/src/core/cache/cache-factory.spec.js +2 -2
- package/src/core/compile/compile.js +0 -33
- package/src/core/compile/compile.spec.js +64 -104
- package/src/core/controller/controller.spec.js +2 -2
- package/src/core/cookie-reader.spec.js +2 -2
- package/src/core/filter/filter.spec.js +4 -4
- package/src/core/interpolate/interpolate.spec.js +2 -2
- package/src/core/interval/interval.spec.js +10 -7
- package/src/core/location/location.js +7 -0
- package/src/core/location/location.spec.js +2 -2
- package/src/core/ng-module.js +167 -0
- package/src/core/on.spec.js +2 -2
- package/src/core/parser/lexer.spec.js +11 -8
- package/src/core/parser/parse.spec.js +11 -8
- package/src/core/prop.spec.js +47 -35
- package/src/core/q/q.spec.js +6 -6
- package/src/core/root-element.spec.js +0 -2
- package/src/core/sce/sce.spec.js +7 -6
- package/src/core/scope/scope.spec.js +11 -8
- package/src/core/timeout/timeout.spec.js +10 -7
- package/src/directive/attrs/attrs.spec.js +4 -3
- package/src/directive/attrs/boolean.spec.js +2 -2
- package/src/directive/attrs/element-style.spec.js +4 -3
- package/src/directive/attrs/src.spec.js +7 -5
- package/src/directive/bind/bind.spec.js +10 -7
- package/src/directive/bind/bing-html.spec.js +2 -2
- package/src/directive/change/change.spec.js +2 -2
- package/src/directive/class/class.spec.js +2 -2
- package/src/directive/cloak/cloak.spec.js +2 -2
- package/src/directive/controller/controller.spec.js +2 -3
- package/src/directive/events/click.spec.js +2 -2
- package/src/directive/events/event.spec.js +16 -13
- package/src/directive/form/form.spec.js +11 -9
- package/src/directive/if/if.spec.js +2 -3
- package/src/directive/include/include.spec.js +11 -10
- package/src/directive/init/init.spec.js +3 -4
- package/src/directive/input/input.spec.js +10 -7
- package/src/directive/list/list.spec.js +2 -2
- package/src/directive/model/model.spec.js +11 -11
- package/src/directive/model-options/model-options.spec.js +11 -9
- package/src/directive/non-bindable/non-bindable.spec.js +10 -7
- package/src/directive/options/options.spec.js +10 -7
- package/src/directive/ref/href.spec.js +11 -8
- package/src/directive/ref/ref.spec.js +10 -7
- package/src/directive/repeat/repeat.spec.js +11 -10
- package/src/directive/script/script.spec.js +4 -3
- package/src/directive/select/select.spec.js +10 -7
- package/src/directive/show-hide/show-hide.spec.js +4 -3
- package/src/directive/style/style.spec.js +9 -6
- package/src/directive/switch/switch.spec.js +2 -2
- package/src/directive/validators/validators.spec.js +12 -9
- package/src/exts/aria/aria.js +2 -2
- package/src/exts/aria/aria.spec.js +2 -2
- package/src/exts/messages/messages.js +2 -2
- package/src/exts/messages/messages.spec.js +2 -2
- package/src/filters/filter.spec.js +4 -3
- package/src/filters/filters.spec.js +4 -3
- package/src/filters/limit-to.spec.js +4 -3
- package/src/filters/order-by.spec.js +7 -5
- package/src/index.js +2 -8
- package/src/injector.js +7 -0
- package/src/injector.spec.js +26 -29
- package/src/loader.js +133 -1126
- package/src/loader.md +142 -0
- package/src/loader.spec.js +5 -9
- package/src/public.js +113 -107
- package/src/public.spec.js +2 -4
- package/src/router/directives/state-directives.spec.js +0 -3
- package/src/router/directives/view-directive.spec.js +0 -6
- package/src/router/index.js +2 -2
- package/src/router/services.spec.js +0 -2
- package/src/router/state/state.spec.js +2 -4
- package/src/router/state-filter.spec.js +0 -2
- package/src/router/template-factory.spec.js +0 -2
- package/src/router/url/url-service.spec.js +0 -2
- package/src/router/view/view.spec.js +1 -2
- package/src/router/view-hook.spec.js +0 -2
- package/src/router/view-scroll.spec.js +0 -3
- package/src/services/http/http.spec.js +2 -2
- package/src/services/http/template-request.spec.js +3 -3
- package/src/services/http-backend/http-backend.spec.js +3 -2
- package/src/shared/jqlite/jqlite.js +20 -29
- package/src/shared/jqlite/jqlite.md +62 -0
- package/src/shared/jqlite/jqlite.spec.js +3 -4
- package/src/shared/min-err.spec.js +1 -2
- package/src/shared/test-utils.js +1 -1
- package/src/shared/utils.js +36 -2
- package/src/types.js +3 -4
- package/types/animations/animate-css-driver.d.ts +2 -1
- package/types/animations/animate-queue.d.ts +2 -1
- package/types/animations/module.d.ts +1 -1
- package/types/core/compile/compile.d.ts +0 -1
- package/types/core/location/location.d.ts +2 -1
- package/types/core/ng-module.d.ts +57 -0
- package/types/exts/aria/aria.d.ts +1 -1
- package/types/exts/messages/messages.d.ts +1 -1
- package/types/index.d.ts +0 -3
- package/types/injector.d.ts +7 -7
- package/types/loader.d.ts +69 -267
- package/types/public.d.ts +6 -1
- package/types/router/index.d.ts +1 -1
- package/types/shared/jqlite/jqlite.d.ts +5 -5
- package/types/shared/test-utils.d.ts +3 -2
- package/types/shared/utils.d.ts +20 -1
- package/types/types.d.ts +3 -3
package/src/loader.js
CHANGED
|
@@ -1,52 +1,31 @@
|
|
|
1
1
|
import {
|
|
2
2
|
minErr,
|
|
3
|
-
extend,
|
|
4
3
|
forEach,
|
|
5
4
|
getNgAttribute,
|
|
6
|
-
isFunction,
|
|
7
|
-
isObject,
|
|
8
5
|
ngAttrPrefixes,
|
|
9
|
-
isDefined,
|
|
10
|
-
isDate,
|
|
11
|
-
isElement,
|
|
12
|
-
isNumber,
|
|
13
|
-
isString,
|
|
14
|
-
isUndefined,
|
|
15
|
-
merge,
|
|
16
|
-
bind,
|
|
17
|
-
fromJson,
|
|
18
|
-
toJson,
|
|
19
|
-
equals,
|
|
20
6
|
assertNotHasOwnProperty,
|
|
21
|
-
|
|
22
|
-
isValidObjectMaxDepth,
|
|
23
|
-
minErrConfig,
|
|
7
|
+
errorHandlingConfig,
|
|
24
8
|
} from "./shared/utils";
|
|
25
|
-
import { JQLite
|
|
9
|
+
import { JQLite } from "./shared/jqlite/jqlite";
|
|
26
10
|
import { createInjector } from "./injector";
|
|
27
11
|
import { CACHE } from "./core/cache/cache";
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*/
|
|
32
|
-
export const VERSION = "[VI]{version}[/VI]";
|
|
12
|
+
import { publishExternalAPI } from "./public";
|
|
13
|
+
import { NgModule } from "./core/ng-module";
|
|
14
|
+
import { VERSION } from "./public";
|
|
33
15
|
|
|
34
16
|
const ngMinErr = minErr("ng");
|
|
17
|
+
const $injectorMinErr = minErr("$injector");
|
|
35
18
|
|
|
36
19
|
/** @type {Object.<string, import('./types').Module>} */
|
|
37
|
-
const
|
|
20
|
+
const modules = {};
|
|
38
21
|
|
|
39
22
|
/**
|
|
40
23
|
* Configuration option for AngularTS bootstrap process.
|
|
41
24
|
*
|
|
42
25
|
* @typedef {Object} AngularBootstrapConfig
|
|
43
|
-
* @property {boolean} debugInfoEnabled - Indicates whether debug information should be enabled. Setting this to `false` can improve performance but will disable some debugging features.
|
|
44
26
|
* @property {boolean} [strictDi] - Disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. Defaults to `false`.
|
|
45
27
|
*/
|
|
46
28
|
|
|
47
|
-
/**
|
|
48
|
-
* @class
|
|
49
|
-
*/
|
|
50
29
|
export class Angular {
|
|
51
30
|
constructor() {
|
|
52
31
|
CACHE.clear(); // a ensure new instance of angular gets a clean cache
|
|
@@ -60,110 +39,98 @@ export class Angular {
|
|
|
60
39
|
/** @type {typeof import('./shared/jqlite/jqlite').JQLite} */
|
|
61
40
|
this.element = JQLite;
|
|
62
41
|
|
|
63
|
-
/** @type {
|
|
64
|
-
this.
|
|
42
|
+
/** @type {!Array<string|any>} */
|
|
43
|
+
this.bootsrappedModules = [];
|
|
65
44
|
|
|
66
45
|
/** @type {Function} */
|
|
67
46
|
this.doBootstrap;
|
|
47
|
+
publishExternalAPI(this);
|
|
68
48
|
}
|
|
69
49
|
|
|
70
50
|
/**
|
|
71
|
-
|
|
72
|
-
|
|
51
|
+
* Configure several aspects of error handling if used as a setter or return the
|
|
52
|
+
* current configuration if used as a getter.
|
|
53
|
+
*
|
|
54
|
+
* Omitted or undefined options will leave the corresponding configuration values unchanged.
|
|
55
|
+
*
|
|
56
|
+
* @param {import('./shared/utils').ErrorHandlingConfig} [config]
|
|
57
|
+
* @returns {import('./shared/utils').ErrorHandlingConfig}
|
|
58
|
+
*/
|
|
59
|
+
errorHandlingConfig(config) {
|
|
60
|
+
return errorHandlingConfig(config);
|
|
61
|
+
}
|
|
73
62
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
*
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
* following keys are supported:
|
|
123
|
-
*
|
|
124
|
-
* * `strictDi` - disable automatic function annotation for the application. This is meant to
|
|
125
|
-
* assist in finding bugs which break minified code. Defaults to `false`.
|
|
126
|
-
*
|
|
127
|
-
* @returns {any} InjectorService - Returns the newly created injector for this app.
|
|
128
|
-
*/
|
|
63
|
+
/**
|
|
64
|
+
* Use this function to manually start up AngularJS application.
|
|
65
|
+
*
|
|
66
|
+
* AngularJS will detect if it has been loaded into the browser more than once and only allow the
|
|
67
|
+
* first loaded script to be bootstrapped and will report a warning to the browser console for
|
|
68
|
+
* each of the subsequent scripts. This prevents strange results in applications, where otherwise
|
|
69
|
+
* multiple instances of AngularJS try to work on the DOM.
|
|
70
|
+
* *
|
|
71
|
+
* <div class="alert alert-warning">
|
|
72
|
+
* **Note:** Do not bootstrap the app on an element with a directive that uses {@link ng.$compile#transclusion transclusion},
|
|
73
|
+
* such as {@link ng.ngIf `ngIf`}, {@link ng.ngInclude `ngInclude`} and {@link ngRoute.ngView `ngView`}.
|
|
74
|
+
* Doing this misplaces the app {@link ng.$rootElement `$rootElement`} and the app's {@link auto.$injector injector},
|
|
75
|
+
* causing animations to stop working and making the injector inaccessible from outside the app.
|
|
76
|
+
* </div>
|
|
77
|
+
*
|
|
78
|
+
* ```html
|
|
79
|
+
* <!doctype html>
|
|
80
|
+
* <html>
|
|
81
|
+
* <body>
|
|
82
|
+
* <div ng-controller="WelcomeController">
|
|
83
|
+
* {{greeting}}
|
|
84
|
+
* </div>
|
|
85
|
+
*
|
|
86
|
+
* <script src="angular.js"></script>
|
|
87
|
+
* <script>
|
|
88
|
+
* let app = angular.module('demo', [])
|
|
89
|
+
* .controller('WelcomeController', function($scope) {
|
|
90
|
+
* $scope.greeting = 'Welcome!';
|
|
91
|
+
* });
|
|
92
|
+
* angular.bootstrap(document, ['demo']);
|
|
93
|
+
* </script>
|
|
94
|
+
* </body>
|
|
95
|
+
* </html>
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @param {string | Element | Document} element DOM element which is the root of AngularJS application.
|
|
99
|
+
* @param {Array<String|any>} [modules] an array of modules to load into the application.
|
|
100
|
+
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
|
101
|
+
* function that will be invoked by the injector as a `config` block.
|
|
102
|
+
* See: {@link angular.module modules}
|
|
103
|
+
* @param {AngularBootstrapConfig} [config] an object for defining configuration options for the application. The
|
|
104
|
+
* following keys are supported:
|
|
105
|
+
*
|
|
106
|
+
* * `strictDi` - disable automatic function annotation for the application. This is meant to
|
|
107
|
+
* assist in finding bugs which break minified code. Defaults to `false`.
|
|
108
|
+
*
|
|
109
|
+
* @returns {any} InjectorService - Returns the newly created injector for this app.
|
|
110
|
+
*/
|
|
129
111
|
bootstrap(element, modules, config) {
|
|
130
112
|
config = config || {
|
|
131
|
-
debugInfoEnabled: false,
|
|
132
113
|
strictDi: false,
|
|
133
114
|
};
|
|
134
115
|
|
|
135
116
|
this.doBootstrap = function () {
|
|
136
|
-
|
|
117
|
+
var jqLite = JQLite(element);
|
|
137
118
|
|
|
138
|
-
if (
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
"App already bootstrapped with this element '{0}'",
|
|
145
|
-
tag.replace(/</, "<").replace(/>/, ">"),
|
|
146
|
-
);
|
|
119
|
+
if (jqLite.injector()) {
|
|
120
|
+
throw ngMinErr("btstrpd", "App already bootstrapped");
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (Array.isArray(modules)) {
|
|
124
|
+
this.bootsrappedModules = modules;
|
|
147
125
|
}
|
|
148
126
|
|
|
149
|
-
this.bootsrappedModules = modules || [];
|
|
150
127
|
this.bootsrappedModules.unshift([
|
|
151
128
|
"$provide",
|
|
152
129
|
($provide) => {
|
|
153
|
-
$provide.value("$rootElement",
|
|
130
|
+
$provide.value("$rootElement", jqLite);
|
|
154
131
|
},
|
|
155
132
|
]);
|
|
156
133
|
|
|
157
|
-
if (config.debugInfoEnabled) {
|
|
158
|
-
// Pushing so that this overrides `debugInfoEnabled` setting defined in user's `modules`.
|
|
159
|
-
this.bootsrappedModules.push([
|
|
160
|
-
"$compileProvider",
|
|
161
|
-
function ($compileProvider) {
|
|
162
|
-
$compileProvider.debugInfoEnabled(true);
|
|
163
|
-
},
|
|
164
|
-
]);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
134
|
this.bootsrappedModules.unshift("ng");
|
|
168
135
|
|
|
169
136
|
const injector = createInjector(this.bootsrappedModules, config.strictDi);
|
|
@@ -172,7 +139,14 @@ export class Angular {
|
|
|
172
139
|
"$rootElement",
|
|
173
140
|
"$compile",
|
|
174
141
|
"$injector",
|
|
175
|
-
|
|
142
|
+
/**
|
|
143
|
+
*
|
|
144
|
+
* @param {*} scope
|
|
145
|
+
* @param {JQLite} el
|
|
146
|
+
* @param {*} compile
|
|
147
|
+
* @param {*} $injector
|
|
148
|
+
*/
|
|
149
|
+
function (scope, el, compile, $injector) {
|
|
176
150
|
scope.$apply(() => {
|
|
177
151
|
el.data("$injector", $injector);
|
|
178
152
|
compile(el)(scope);
|
|
@@ -182,36 +156,26 @@ export class Angular {
|
|
|
182
156
|
return injector;
|
|
183
157
|
};
|
|
184
158
|
|
|
185
|
-
const NG_ENABLE_DEBUG_INFO = /^NG_ENABLE_DEBUG_INFO!/;
|
|
186
159
|
const NG_DEFER_BOOTSTRAP = /^NG_DEFER_BOOTSTRAP!/;
|
|
187
160
|
|
|
188
|
-
if (window && NG_ENABLE_DEBUG_INFO.test(window.name)) {
|
|
189
|
-
config.debugInfoEnabled = true;
|
|
190
|
-
window.name = window.name.replace(NG_ENABLE_DEBUG_INFO, "");
|
|
191
|
-
}
|
|
192
|
-
|
|
193
161
|
if (window && !NG_DEFER_BOOTSTRAP.test(window.name)) {
|
|
194
162
|
return this.doBootstrap();
|
|
195
163
|
}
|
|
196
164
|
|
|
197
165
|
window.name = window.name.replace(NG_DEFER_BOOTSTRAP, "");
|
|
198
166
|
this.resumeBootstrap = function (extraModules) {
|
|
199
|
-
|
|
200
|
-
modules.push(module);
|
|
201
|
-
}
|
|
167
|
+
if (Array.isArray(extraModules)) {
|
|
168
|
+
extraModules.forEach((module) => modules.push(module));
|
|
169
|
+
}
|
|
202
170
|
return this.doBootstrap();
|
|
203
171
|
};
|
|
204
|
-
|
|
205
|
-
if (isFunction(this.resumeDeferredBootstrap)) {
|
|
206
|
-
this.resumeDeferredBootstrap();
|
|
207
|
-
}
|
|
208
172
|
}
|
|
209
173
|
|
|
210
174
|
/**
|
|
211
175
|
*
|
|
212
176
|
* @param {any[]} modules
|
|
213
177
|
* @param {boolean?} strictDi
|
|
214
|
-
* @returns {
|
|
178
|
+
* @returns {import("./types").InjectorService}
|
|
215
179
|
*/
|
|
216
180
|
injector(modules, strictDi) {
|
|
217
181
|
return createInjector(modules, strictDi);
|
|
@@ -224,6 +188,42 @@ export class Angular {
|
|
|
224
188
|
return this.doBootstrap();
|
|
225
189
|
}
|
|
226
190
|
|
|
191
|
+
/**
|
|
192
|
+
* @param {Element|Document} element
|
|
193
|
+
*/
|
|
194
|
+
init(element) {
|
|
195
|
+
let appElement;
|
|
196
|
+
let module;
|
|
197
|
+
const config = {};
|
|
198
|
+
// The element `element` has priority over any other element.
|
|
199
|
+
ngAttrPrefixes.forEach((prefix) => {
|
|
200
|
+
const name = `${prefix}app`;
|
|
201
|
+
if (
|
|
202
|
+
/** @type {Element} */ (element).hasAttribute &&
|
|
203
|
+
/** @type {Element} */ (element).hasAttribute(name)
|
|
204
|
+
) {
|
|
205
|
+
appElement = element;
|
|
206
|
+
module = /** @type {Element} */ (element).getAttribute(name);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
ngAttrPrefixes.forEach((prefix) => {
|
|
210
|
+
const name = `${prefix}app`;
|
|
211
|
+
let candidate;
|
|
212
|
+
|
|
213
|
+
if (
|
|
214
|
+
!appElement &&
|
|
215
|
+
(candidate = element.querySelector(`[${name.replace(":", "\\:")}]`))
|
|
216
|
+
) {
|
|
217
|
+
appElement = candidate;
|
|
218
|
+
module = candidate.getAttribute(name);
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
if (appElement) {
|
|
222
|
+
config.strictDi = getNgAttribute(appElement, "strict-di") !== null;
|
|
223
|
+
this.bootstrap(appElement, module ? [module] : [], config);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
227
|
/**
|
|
228
228
|
*
|
|
229
229
|
* The `angular.module` is a global place for creating, registering and retrieving AngularJS
|
|
@@ -269,1020 +269,27 @@ export class Angular {
|
|
|
269
269
|
* unspecified then the module is being retrieved for further configuration.
|
|
270
270
|
* @param {Function=} configFn Optional configuration function for the module. Same as
|
|
271
271
|
* {@link import('./types').Module#config Module#config()}.
|
|
272
|
-
* @returns {
|
|
272
|
+
* @returns {NgModule} A newly registered module.
|
|
273
273
|
*/
|
|
274
274
|
module(name, requires, configFn) {
|
|
275
|
-
const $injectorMinErr = minErr("$injector");
|
|
276
|
-
let info = {};
|
|
277
|
-
|
|
278
275
|
assertNotHasOwnProperty(name, "module");
|
|
279
|
-
if (requires && Object.prototype.hasOwnProperty.call(
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
function ensure(obj, name, factory) {
|
|
284
|
-
return obj[name] || (obj[name] = factory());
|
|
276
|
+
if (requires && Object.prototype.hasOwnProperty.call(modules, name)) {
|
|
277
|
+
modules[name] = null;
|
|
285
278
|
}
|
|
286
|
-
|
|
287
|
-
return ensure(moduleCache, name, () => {
|
|
279
|
+
return ensure(modules, name, () => {
|
|
288
280
|
if (!requires) {
|
|
289
281
|
throw $injectorMinErr(
|
|
290
282
|
"nomod",
|
|
291
|
-
"Module '{0}' is not available
|
|
292
|
-
"the module name or forgot to load it. If registering a module ensure that you " +
|
|
293
|
-
"specify the dependencies as the second argument.",
|
|
283
|
+
"Module '{0}' is not available. Possibly misspelled or not loaded",
|
|
294
284
|
name,
|
|
295
285
|
);
|
|
296
286
|
}
|
|
297
|
-
|
|
298
|
-
/** @type {!Array.<Array.<*>>} */
|
|
299
|
-
const invokeQueue = [];
|
|
300
|
-
|
|
301
|
-
/** @type {!Array.<Function>} */
|
|
302
|
-
const configBlocks = [];
|
|
303
|
-
|
|
304
|
-
/** @type {!Array.<Function>} */
|
|
305
|
-
const runBlocks = [];
|
|
306
|
-
|
|
307
|
-
const config = invokeLater("$injector", "invoke", "push", configBlocks);
|
|
308
|
-
|
|
309
|
-
/** @type {import('./types').Module} */
|
|
310
|
-
const moduleInstance = {
|
|
311
|
-
// Private state
|
|
312
|
-
|
|
313
|
-
_invokeQueue: invokeQueue,
|
|
314
|
-
_configBlocks: configBlocks,
|
|
315
|
-
_runBlocks: runBlocks,
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* @ngdoc method
|
|
319
|
-
* @name import('./types').Module#info
|
|
320
|
-
* @module ng
|
|
321
|
-
*
|
|
322
|
-
* @param {Object=} value Information about the module
|
|
323
|
-
* @returns {Object|import('./types').Module} The current info object for this module if called as a getter,
|
|
324
|
-
* or `this` if called as a setter.
|
|
325
|
-
*
|
|
326
|
-
* @description
|
|
327
|
-
* Read and write custom information about this module.
|
|
328
|
-
* For example you could put the version of the module in here.
|
|
329
|
-
*
|
|
330
|
-
* ```js
|
|
331
|
-
* angular.module('myModule', []).info({ version: '1.0.0' });
|
|
332
|
-
* ```
|
|
333
|
-
*
|
|
334
|
-
* The version could then be read back out by accessing the module elsewhere:
|
|
335
|
-
*
|
|
336
|
-
* ```
|
|
337
|
-
* let version = angular.module('myModule').info().version;
|
|
338
|
-
* ```
|
|
339
|
-
*
|
|
340
|
-
* You can also retrieve this information during runtime via the
|
|
341
|
-
* {@link $injector#modules `$injector.modules`} property:
|
|
342
|
-
*
|
|
343
|
-
* ```js
|
|
344
|
-
* let version = $injector.modules['myModule'].info().version;
|
|
345
|
-
* ```
|
|
346
|
-
*/
|
|
347
|
-
info(value) {
|
|
348
|
-
if (isDefined(value)) {
|
|
349
|
-
if (!isObject(value))
|
|
350
|
-
throw ngMinErr(
|
|
351
|
-
"aobj",
|
|
352
|
-
"Argument '{0}' must be an object",
|
|
353
|
-
"value",
|
|
354
|
-
);
|
|
355
|
-
info = value;
|
|
356
|
-
return this;
|
|
357
|
-
}
|
|
358
|
-
return info;
|
|
359
|
-
},
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* @ngdoc property
|
|
363
|
-
* @type import('./types').Module#requires
|
|
364
|
-
* @module ng
|
|
365
|
-
*
|
|
366
|
-
* @description
|
|
367
|
-
* Holds the list of modules which the injector will load before the current module is
|
|
368
|
-
* loaded.
|
|
369
|
-
*/
|
|
370
|
-
requires,
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* @ngdoc property
|
|
374
|
-
* @name import('./types').Module#name
|
|
375
|
-
* @module ng
|
|
376
|
-
*
|
|
377
|
-
* @description
|
|
378
|
-
* Name of the module.
|
|
379
|
-
*/
|
|
380
|
-
name,
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* @ngdoc method
|
|
384
|
-
* @name import('./types').Module#provider
|
|
385
|
-
* @module ng
|
|
386
|
-
* @param {string} name service name
|
|
387
|
-
* @param {Function} providerType Construction function for creating new instance of the
|
|
388
|
-
* service.
|
|
389
|
-
* @description
|
|
390
|
-
* See {@link auto.$provide#provider $provide.provider()}.
|
|
391
|
-
*/
|
|
392
|
-
provider: invokeLaterAndSetModuleName("$provide", "provider"),
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* @ngdoc method
|
|
396
|
-
* @name import('./types').Module#factory
|
|
397
|
-
* @module ng
|
|
398
|
-
* @param {string} name service name
|
|
399
|
-
* @param {Function} providerFunction Function for creating new instance of the service.
|
|
400
|
-
* @description
|
|
401
|
-
* See {@link auto.$provide#factory $provide.factory()}.
|
|
402
|
-
*/
|
|
403
|
-
factory: invokeLaterAndSetModuleName("$provide", "factory"),
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* @ngdoc method
|
|
407
|
-
* @name import('./types').Module#service
|
|
408
|
-
* @module ng
|
|
409
|
-
* @param {string} name service name
|
|
410
|
-
* @param {Function} constructor A constructor function that will be instantiated.
|
|
411
|
-
* @description
|
|
412
|
-
* See {@link auto.$provide#service $provide.service()}.
|
|
413
|
-
*/
|
|
414
|
-
service: invokeLaterAndSetModuleName("$provide", "service"),
|
|
415
|
-
|
|
416
|
-
/**
|
|
417
|
-
* @ngdoc method
|
|
418
|
-
* @name import('./types').Module#value
|
|
419
|
-
* @module ng
|
|
420
|
-
* @param {string} name service name
|
|
421
|
-
* @param {*} object Service instance object.
|
|
422
|
-
* @description
|
|
423
|
-
* See {@link auto.$provide#value $provide.value()}.
|
|
424
|
-
*/
|
|
425
|
-
value: invokeLater("$provide", "value"),
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* @ngdoc method
|
|
429
|
-
* @name import('./types').Module#constant
|
|
430
|
-
* @module ng
|
|
431
|
-
* @param {string} name constant name
|
|
432
|
-
* @param {*} object Constant value.
|
|
433
|
-
* @description
|
|
434
|
-
* Because the constants are fixed, they get applied before other provide methods.
|
|
435
|
-
* See {@link auto.$provide#constant $provide.constant()}.
|
|
436
|
-
*/
|
|
437
|
-
constant: invokeLater("$provide", "constant", "unshift"),
|
|
438
|
-
|
|
439
|
-
/**
|
|
440
|
-
* @ngdoc method
|
|
441
|
-
* @name import('./types').Module#decorator
|
|
442
|
-
* @module ng
|
|
443
|
-
* @param {string} name The name of the service to decorate.
|
|
444
|
-
* @param {Function} decorFn This function will be invoked when the service needs to be
|
|
445
|
-
* instantiated and should return the decorated service instance.
|
|
446
|
-
* @description
|
|
447
|
-
* See {@link auto.$provide#decorator $provide.decorator()}.
|
|
448
|
-
*/
|
|
449
|
-
decorator: invokeLaterAndSetModuleName(
|
|
450
|
-
"$provide",
|
|
451
|
-
"decorator",
|
|
452
|
-
configBlocks,
|
|
453
|
-
),
|
|
454
|
-
|
|
455
|
-
/**
|
|
456
|
-
* @ngdoc method
|
|
457
|
-
* @name import('./types').Module#animation
|
|
458
|
-
* @module ng
|
|
459
|
-
* @param {string} name animation name
|
|
460
|
-
* @param {Function} animationFactory Factory function for creating new instance of an
|
|
461
|
-
* animation.
|
|
462
|
-
* @description
|
|
463
|
-
*
|
|
464
|
-
* **NOTE**: animations take effect only if the **ngAnimate** module is loaded.
|
|
465
|
-
*
|
|
466
|
-
*
|
|
467
|
-
* Defines an animation hook that can be later used with
|
|
468
|
-
* {@link $animate $animate} service and directives that use this service.
|
|
469
|
-
*
|
|
470
|
-
* ```js
|
|
471
|
-
* module.animation('.animation-name', function($inject1, $inject2) {
|
|
472
|
-
* return {
|
|
473
|
-
* eventName : function(element, done) {
|
|
474
|
-
* //code to run the animation
|
|
475
|
-
* //once complete, then run done()
|
|
476
|
-
* return function cancellationFunction(element) {
|
|
477
|
-
* //code to cancel the animation
|
|
478
|
-
* }
|
|
479
|
-
* }
|
|
480
|
-
* }
|
|
481
|
-
* })
|
|
482
|
-
* ```
|
|
483
|
-
*
|
|
484
|
-
* See {@link ng.$animateProvider#register $animateProvider.register()} and
|
|
485
|
-
* {@link ngAnimate ngAnimate module} for more information.
|
|
486
|
-
*/
|
|
487
|
-
animation: invokeLaterAndSetModuleName("$animateProvider", "register"),
|
|
488
|
-
|
|
489
|
-
/**
|
|
490
|
-
* @ngdoc method
|
|
491
|
-
* @name import('./types').Module#filter
|
|
492
|
-
* @module ng
|
|
493
|
-
* @param {string} name Filter name - this must be a valid AngularJS expression identifier
|
|
494
|
-
* @param {Function} filterFactory Factory function for creating new instance of filter.
|
|
495
|
-
* @description
|
|
496
|
-
* See {@link ng.$filterProvider#register $filterProvider.register()}.
|
|
497
|
-
*
|
|
498
|
-
* <div class="alert alert-warning">
|
|
499
|
-
* **Note:** Filter names must be valid AngularJS {@link expression} identifiers, such as `uppercase` or `orderBy`.
|
|
500
|
-
* Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace
|
|
501
|
-
* your filters, then you can use capitalization (`myappSubsectionFilterx`) or underscores
|
|
502
|
-
* (`myapp_subsection_filterx`).
|
|
503
|
-
* </div>
|
|
504
|
-
*/
|
|
505
|
-
filter: invokeLaterAndSetModuleName("$filterProvider", "register"),
|
|
506
|
-
|
|
507
|
-
/**
|
|
508
|
-
* @ngdoc method
|
|
509
|
-
* @name import('./types').Module#controller
|
|
510
|
-
* @module ng
|
|
511
|
-
* @param {string|Object} name Controller name, or an object map of controllers where the
|
|
512
|
-
* keys are the names and the values are the constructors.
|
|
513
|
-
* @param {Function} constructor Controller constructor function.
|
|
514
|
-
* @description
|
|
515
|
-
* See {@link ng.$controllerProvider#register $controllerProvider.register()}.
|
|
516
|
-
*/
|
|
517
|
-
controller: invokeLaterAndSetModuleName(
|
|
518
|
-
"$controllerProvider",
|
|
519
|
-
"register",
|
|
520
|
-
),
|
|
521
|
-
|
|
522
|
-
/**
|
|
523
|
-
* @ngdoc method
|
|
524
|
-
* @name import('./types').Module#directive
|
|
525
|
-
* @module ng
|
|
526
|
-
* @param {string|Object} name Directive name, or an object map of directives where the
|
|
527
|
-
* keys are the names and the values are the factories.
|
|
528
|
-
* @param {Function} directiveFactory Factory function for creating new instance of
|
|
529
|
-
* directives.
|
|
530
|
-
* @description
|
|
531
|
-
* See {@link ng.$compileProvider#directive $compileProvider.directive()}.
|
|
532
|
-
*/
|
|
533
|
-
directive: invokeLaterAndSetModuleName("$compileProvider", "directive"),
|
|
534
|
-
|
|
535
|
-
/**
|
|
536
|
-
* @ngdoc method
|
|
537
|
-
* @name import('./types').Module#component
|
|
538
|
-
* @module ng
|
|
539
|
-
* @param {string|Object} name Name of the component in camelCase (i.e. `myComp` which will match `<my-comp>`),
|
|
540
|
-
* or an object map of components where the keys are the names and the values are the component definition objects.
|
|
541
|
-
* @param {Object} options Component definition object (a simplified
|
|
542
|
-
* {@link ng.$compile#directive-definition-object directive definition object})
|
|
543
|
-
*
|
|
544
|
-
* @description
|
|
545
|
-
* See {@link ng.$compileProvider#component $compileProvider.component()}.
|
|
546
|
-
*/
|
|
547
|
-
component: invokeLaterAndSetModuleName("$compileProvider", "component"),
|
|
548
|
-
|
|
549
|
-
/**
|
|
550
|
-
* @ngdoc method
|
|
551
|
-
* @name import('./types').Module#config
|
|
552
|
-
* @module ng
|
|
553
|
-
* @param {Function} configFn Execute this function on module load. Useful for service
|
|
554
|
-
* configuration.
|
|
555
|
-
* @description
|
|
556
|
-
* Use this method to configure services by injecting their
|
|
557
|
-
* {@link import('./types').Module#provider `providers`}, e.g. for adding routes to the
|
|
558
|
-
* {@link ngRoute.$routeProvider $routeProvider}.
|
|
559
|
-
*
|
|
560
|
-
* Note that you can only inject {@link import('./types').Module#provider `providers`} and
|
|
561
|
-
* {@link import('./types').Module#constant `constants`} into this function.
|
|
562
|
-
*
|
|
563
|
-
* For more about how to configure services, see
|
|
564
|
-
* {@link providers#provider-recipe Provider Recipe}.
|
|
565
|
-
*/
|
|
566
|
-
config,
|
|
567
|
-
|
|
568
|
-
/**
|
|
569
|
-
* @ngdoc method
|
|
570
|
-
* @name import('./types').Module#run
|
|
571
|
-
* @module ng
|
|
572
|
-
* @param {Function} initializationFn Execute this function after injector creation.
|
|
573
|
-
* Useful for application initialization.
|
|
574
|
-
* @description
|
|
575
|
-
* Use this method to register work which should be performed when the injector is done
|
|
576
|
-
* loading all modules.
|
|
577
|
-
*/
|
|
578
|
-
run(block) {
|
|
579
|
-
runBlocks.push(block);
|
|
580
|
-
return this;
|
|
581
|
-
},
|
|
582
|
-
};
|
|
583
|
-
|
|
584
|
-
if (configFn) {
|
|
585
|
-
config(configFn);
|
|
586
|
-
}
|
|
587
|
-
|
|
287
|
+
const moduleInstance = new NgModule(name, requires, configFn);
|
|
588
288
|
return moduleInstance;
|
|
589
|
-
|
|
590
|
-
/**
|
|
591
|
-
* @param {string} provider
|
|
592
|
-
* @param {string} method
|
|
593
|
-
* @param {String=} insertMethod
|
|
594
|
-
* @returns {import('./types').Module}
|
|
595
|
-
*/
|
|
596
|
-
function invokeLater(provider, method, insertMethod, queue) {
|
|
597
|
-
if (!queue) queue = invokeQueue;
|
|
598
|
-
return function () {
|
|
599
|
-
queue[insertMethod || "push"]([provider, method, arguments]);
|
|
600
|
-
return moduleInstance;
|
|
601
|
-
};
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
/**
|
|
605
|
-
* @param {string} provider
|
|
606
|
-
* @param {string} method
|
|
607
|
-
* @returns {import('./types').Module}
|
|
608
|
-
*/
|
|
609
|
-
function invokeLaterAndSetModuleName(provider, method, queue) {
|
|
610
|
-
if (!queue) queue = invokeQueue;
|
|
611
|
-
return function (recipeName, factoryFunction) {
|
|
612
|
-
if (factoryFunction && isFunction(factoryFunction))
|
|
613
|
-
factoryFunction.$$moduleName = name;
|
|
614
|
-
queue.push([provider, method, arguments]);
|
|
615
|
-
return moduleInstance;
|
|
616
|
-
};
|
|
617
|
-
}
|
|
618
289
|
});
|
|
619
290
|
}
|
|
620
|
-
|
|
621
|
-
/**
|
|
622
|
-
* @module angular
|
|
623
|
-
* @function reloadWithDebugInfo
|
|
624
|
-
|
|
625
|
-
* @description
|
|
626
|
-
* Use this function to reload the current application with debug information turned on.
|
|
627
|
-
* This takes precedence over a call to `$compileProvider.debugInfoEnabled(false)`.
|
|
628
|
-
*
|
|
629
|
-
* See {@link ng.$compileProvider#debugInfoEnabled} for more.
|
|
630
|
-
*/
|
|
631
|
-
reloadWithDebugInfo() {
|
|
632
|
-
window.name = `NG_ENABLE_DEBUG_INFO!${window.name}`;
|
|
633
|
-
window.location.reload();
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
/// //////////////////////////////////////////////
|
|
638
|
-
|
|
639
|
-
/**
|
|
640
|
-
* @ngdoc directive
|
|
641
|
-
* @name ngApp
|
|
642
|
-
*
|
|
643
|
-
* @element ANY
|
|
644
|
-
* @param {import('./types').Module} ngApp an optional application
|
|
645
|
-
* {@link angular.module module} name to load.
|
|
646
|
-
* @param {boolean=} ngStrictDi if this attribute is present on the app element, the injector will be
|
|
647
|
-
* created in "strict-di" mode. This means that the application will fail to invoke functions which
|
|
648
|
-
* do not use explicit function annotation (and are thus unsuitable for minification), as described
|
|
649
|
-
* in {@link guide/di the Dependency Injection guide}, and useful debugging info will assist in
|
|
650
|
-
* tracking down the root of these bugs.
|
|
651
|
-
*
|
|
652
|
-
* @description
|
|
653
|
-
*
|
|
654
|
-
* Use this directive to **auto-bootstrap** an AngularJS application. The `ngApp` directive
|
|
655
|
-
* designates the **root element** of the application and is typically placed near the root element
|
|
656
|
-
* of the page - e.g. on the `<body>` or `<html>` tags.
|
|
657
|
-
*
|
|
658
|
-
* There are a few things to keep in mind when using `ngApp`:
|
|
659
|
-
* - only one AngularJS application can be auto-bootstrapped per HTML document. The first `ngApp`
|
|
660
|
-
* found in the document will be used to define the root element to auto-bootstrap as an
|
|
661
|
-
* application. To run multiple applications in an HTML document you must manually bootstrap them using
|
|
662
|
-
* {@link angular.bootstrap} instead.
|
|
663
|
-
* - AngularJS applications cannot be nested within each other.
|
|
664
|
-
* - Do not use a directive that uses {@link ng.$compile#transclusion transclusion} on the same element as `ngApp`.
|
|
665
|
-
* This includes directives such as {@link ng.ngIf `ngIf`}, {@link ng.ngInclude `ngInclude`} and
|
|
666
|
-
* {@link ngRoute.ngView `ngView`}.
|
|
667
|
-
* Doing this misplaces the app {@link ng.$rootElement `$rootElement`} and the app's {@link auto.$injector injector},
|
|
668
|
-
* causing animations to stop working and making the injector inaccessible from outside the app.
|
|
669
|
-
*
|
|
670
|
-
* You can specify an **AngularJS module** to be used as the root module for the application. This
|
|
671
|
-
* module will be loaded into the {@link auto.$injector} when the application is bootstrapped. It
|
|
672
|
-
* should contain the application code needed or have dependencies on other modules that will
|
|
673
|
-
* contain the code. See {@link angular.module} for more information.
|
|
674
|
-
*
|
|
675
|
-
* In the example below if the `ngApp` directive were not placed on the `html` element then the
|
|
676
|
-
* document would not be compiled, the `AppController` would not be instantiated and the `{{ a+b }}`
|
|
677
|
-
* would not be resolved to `3`.
|
|
678
|
-
*
|
|
679
|
-
* @example
|
|
680
|
-
*
|
|
681
|
-
* ### Simple Usage
|
|
682
|
-
*
|
|
683
|
-
* `ngApp` is the easiest, and most common way to bootstrap an application.
|
|
684
|
-
*
|
|
685
|
-
<example module="ngAppDemo" name="ng-app">
|
|
686
|
-
<file name="index.html">
|
|
687
|
-
<div ng-controller="ngAppDemoController">
|
|
688
|
-
I can add: {{a}} + {{b}} = {{ a+b }}
|
|
689
|
-
</div>
|
|
690
|
-
</file>
|
|
691
|
-
<file name="script.js">
|
|
692
|
-
angular.module('ngAppDemo', []).controller('ngAppDemoController', function($scope) {
|
|
693
|
-
$scope.a = 1;
|
|
694
|
-
$scope.b = 2;
|
|
695
|
-
});
|
|
696
|
-
</file>
|
|
697
|
-
</example>
|
|
698
|
-
*
|
|
699
|
-
* @example
|
|
700
|
-
*
|
|
701
|
-
* ### With `ngStrictDi`
|
|
702
|
-
*
|
|
703
|
-
* Using `ngStrictDi`, you would see something like this:
|
|
704
|
-
*
|
|
705
|
-
<example ng-app-included="true" name="strict-di">
|
|
706
|
-
<file name="index.html">
|
|
707
|
-
<div ng-app="ngAppStrictDemo" ng-strict-di>
|
|
708
|
-
<div ng-controller="GoodController1">
|
|
709
|
-
I can add: {{a}} + {{b}} = {{ a+b }}
|
|
710
|
-
|
|
711
|
-
<p>This renders because the controller does not fail to
|
|
712
|
-
instantiate, by using explicit annotation style (see
|
|
713
|
-
script.js for details)
|
|
714
|
-
</p>
|
|
715
|
-
</div>
|
|
716
|
-
|
|
717
|
-
<div ng-controller="GoodController2">
|
|
718
|
-
Name: <input ng-model="name"><br />
|
|
719
|
-
Hello, {{name}}!
|
|
720
|
-
|
|
721
|
-
<p>This renders because the controller does not fail to
|
|
722
|
-
instantiate, by using explicit annotation style
|
|
723
|
-
(see script.js for details)
|
|
724
|
-
</p>
|
|
725
|
-
</div>
|
|
726
|
-
|
|
727
|
-
<div ng-controller="BadController">
|
|
728
|
-
I can add: {{a}} + {{b}} = {{ a+b }}
|
|
729
|
-
|
|
730
|
-
<p>The controller could not be instantiated, due to relying
|
|
731
|
-
on automatic function annotations (which are disabled in
|
|
732
|
-
strict mode). As such, the content of this section is not
|
|
733
|
-
interpolated, and there should be an error in your web console.
|
|
734
|
-
</p>
|
|
735
|
-
</div>
|
|
736
|
-
</div>
|
|
737
|
-
</file>
|
|
738
|
-
<file name="script.js">
|
|
739
|
-
angular.module('ngAppStrictDemo', [])
|
|
740
|
-
// BadController will fail to instantiate, due to relying on automatic function annotation,
|
|
741
|
-
// rather than an explicit annotation
|
|
742
|
-
.controller('BadController', function($scope) {
|
|
743
|
-
$scope.a = 1;
|
|
744
|
-
$scope.b = 2;
|
|
745
|
-
})
|
|
746
|
-
// Unlike BadController, GoodController1 and GoodController2 will not fail to be instantiated,
|
|
747
|
-
// due to using explicit annotations using the array style and $inject property, respectively.
|
|
748
|
-
.controller('GoodController1', ['$scope', function($scope) {
|
|
749
|
-
$scope.a = 1;
|
|
750
|
-
$scope.b = 2;
|
|
751
|
-
}])
|
|
752
|
-
.controller('GoodController2', GoodController2);
|
|
753
|
-
function GoodController2($scope) {
|
|
754
|
-
$scope.name = 'World';
|
|
755
|
-
}
|
|
756
|
-
GoodController2.$inject = ['$scope'];
|
|
757
|
-
</file>
|
|
758
|
-
<file name="style.css">
|
|
759
|
-
div[ng-controller] {
|
|
760
|
-
margin-bottom: 1em;
|
|
761
|
-
-webkit-border-radius: 4px;
|
|
762
|
-
border-radius: 4px;
|
|
763
|
-
border: 1px solid;
|
|
764
|
-
padding: .5em;
|
|
765
|
-
}
|
|
766
|
-
div[ng-controller^=Good] {
|
|
767
|
-
border-color: #d6e9c6;
|
|
768
|
-
background-color: #dff0d8;
|
|
769
|
-
color: #3c763d;
|
|
770
|
-
}
|
|
771
|
-
div[ng-controller^=Bad] {
|
|
772
|
-
border-color: #ebccd1;
|
|
773
|
-
background-color: #f2dede;
|
|
774
|
-
color: #a94442;
|
|
775
|
-
margin-bottom: 0;
|
|
776
|
-
}
|
|
777
|
-
</file>
|
|
778
|
-
</example>
|
|
779
|
-
*/
|
|
780
|
-
export function angularInit(element) {
|
|
781
|
-
let appElement;
|
|
782
|
-
let module;
|
|
783
|
-
const config = {};
|
|
784
|
-
|
|
785
|
-
// The element `element` has priority over any other element.
|
|
786
|
-
ngAttrPrefixes.forEach((prefix) => {
|
|
787
|
-
const name = `${prefix}app`;
|
|
788
|
-
|
|
789
|
-
if (!appElement && element.hasAttribute && element.hasAttribute(name)) {
|
|
790
|
-
appElement = element;
|
|
791
|
-
module = element.getAttribute(name);
|
|
792
|
-
}
|
|
793
|
-
});
|
|
794
|
-
ngAttrPrefixes.forEach((prefix) => {
|
|
795
|
-
const name = `${prefix}app`;
|
|
796
|
-
let candidate;
|
|
797
|
-
|
|
798
|
-
if (
|
|
799
|
-
!appElement &&
|
|
800
|
-
(candidate = element.querySelector(`[${name.replace(":", "\\:")}]`))
|
|
801
|
-
) {
|
|
802
|
-
appElement = candidate;
|
|
803
|
-
module = candidate.getAttribute(name);
|
|
804
|
-
}
|
|
805
|
-
});
|
|
806
|
-
if (appElement) {
|
|
807
|
-
// Angular init is called manually, so why is this check here
|
|
808
|
-
// if (!confGlobal.isAutoBootstrapAllowed) {
|
|
809
|
-
// window.console.error(
|
|
810
|
-
// "AngularJS: disabling automatic bootstrap. <script> protocol indicates an extension, document.location.href does not match.",
|
|
811
|
-
// );
|
|
812
|
-
// return;
|
|
813
|
-
// }
|
|
814
|
-
config.strictDi = getNgAttribute(appElement, "strict-di") !== null;
|
|
815
|
-
//TODO maybe angular should be initialized here?
|
|
816
|
-
window["angular"].bootstrap(appElement, module ? [module] : [], config);
|
|
817
|
-
}
|
|
818
291
|
}
|
|
819
292
|
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
* @name import('./types').Module
|
|
823
|
-
* @module ng
|
|
824
|
-
* @description
|
|
825
|
-
*
|
|
826
|
-
* Interface for configuring AngularJS {@link angular.module modules}.
|
|
827
|
-
*/
|
|
828
|
-
export function setupModuleLoader(window) {
|
|
829
|
-
const $injectorMinErr = minErr("$injector");
|
|
830
|
-
|
|
831
|
-
function ensure(obj, name, factory) {
|
|
832
|
-
return obj[name] || (obj[name] = factory());
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
const angular = ensure(window, "angular", Object);
|
|
836
|
-
|
|
837
|
-
// We need to expose `angular.$$minErr` to modules such as `ngResource` that reference it during bootstrap
|
|
838
|
-
angular.$$minErr = angular.$$minErr || minErr;
|
|
839
|
-
|
|
840
|
-
return ensure(angular, "module", () => {
|
|
841
|
-
/** @type {Object.<string, import('./types').Module>} */
|
|
842
|
-
const modules = {};
|
|
843
|
-
|
|
844
|
-
/**
|
|
845
|
-
* @ngdoc function
|
|
846
|
-
* @name angular.module
|
|
847
|
-
* @module ng
|
|
848
|
-
* @description
|
|
849
|
-
*
|
|
850
|
-
* The `angular.module` is a global place for creating, registering and retrieving AngularJS
|
|
851
|
-
* modules.
|
|
852
|
-
* All modules (AngularJS core or 3rd party) that should be available to an application must be
|
|
853
|
-
* registered using this mechanism.
|
|
854
|
-
*
|
|
855
|
-
* Passing one argument retrieves an existing {@link import('./types').Module},
|
|
856
|
-
* whereas passing more than one argument creates a new {@link import('./types').Module}
|
|
857
|
-
*
|
|
858
|
-
*
|
|
859
|
-
* # Module
|
|
860
|
-
*
|
|
861
|
-
* A module is a collection of services, directives, controllers, filters, and configuration information.
|
|
862
|
-
* `angular.module` is used to configure the {@link auto.$injector $injector}.
|
|
863
|
-
*
|
|
864
|
-
* ```js
|
|
865
|
-
* // Create a new module
|
|
866
|
-
* let myModule = angular.module('myModule', []);
|
|
867
|
-
*
|
|
868
|
-
* // register a new service
|
|
869
|
-
* myModule.value('appName', 'MyCoolApp');
|
|
870
|
-
*
|
|
871
|
-
* // configure existing services inside initialization blocks.
|
|
872
|
-
* myModule.config(['$locationProvider', function($locationProvider) {
|
|
873
|
-
* // Configure existing providers
|
|
874
|
-
* $locationProvider.hashPrefix('!');
|
|
875
|
-
* }]);
|
|
876
|
-
* ```
|
|
877
|
-
*
|
|
878
|
-
* Then you can create an injector and load your modules like this:
|
|
879
|
-
*
|
|
880
|
-
* ```js
|
|
881
|
-
* let injector = angular.injector(['ng', 'myModule'])
|
|
882
|
-
* ```
|
|
883
|
-
*
|
|
884
|
-
* However it's more likely that you'll just use
|
|
885
|
-
* {@link ng.directive:ngApp ngApp} or
|
|
886
|
-
* {@link angular.bootstrap} to simplify this process for you.
|
|
887
|
-
*
|
|
888
|
-
* @param {!string} name The name of the module to create or retrieve.
|
|
889
|
-
* @param {!Array.<string>=} requires If specified then new module is being created. If
|
|
890
|
-
* unspecified then the module is being retrieved for further configuration.
|
|
891
|
-
* @param {Function=} configFn Optional configuration function for the module. Same as
|
|
892
|
-
* {@link import('./types').Module#config Module#config()}.
|
|
893
|
-
* @returns {import('./types').Module} new module with the {@link import('./types').Module} api.
|
|
894
|
-
*/
|
|
895
|
-
return function module(name, requires, configFn) {
|
|
896
|
-
let info = {};
|
|
897
|
-
|
|
898
|
-
assertNotHasOwnProperty(name, "module");
|
|
899
|
-
if (requires && Object.prototype.hasOwnProperty.call(modules, name)) {
|
|
900
|
-
modules[name] = null;
|
|
901
|
-
}
|
|
902
|
-
return ensure(modules, name, () => {
|
|
903
|
-
if (!requires) {
|
|
904
|
-
throw $injectorMinErr(
|
|
905
|
-
"nomod",
|
|
906
|
-
"Module '{0}' is not available! You either misspelled " +
|
|
907
|
-
"the module name or forgot to load it. If registering a module ensure that you " +
|
|
908
|
-
"specify the dependencies as the second argument.",
|
|
909
|
-
name,
|
|
910
|
-
);
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
/** @type {!Array.<Array.<*>>} */
|
|
914
|
-
const invokeQueue = [];
|
|
915
|
-
|
|
916
|
-
/** @type {!Array.<Function>} */
|
|
917
|
-
const configBlocks = [];
|
|
918
|
-
|
|
919
|
-
/** @type {!Array.<Function>} */
|
|
920
|
-
const runBlocks = [];
|
|
921
|
-
|
|
922
|
-
const config = invokeLater("$injector", "invoke", "push", configBlocks);
|
|
923
|
-
|
|
924
|
-
/** @type {import('./types').Module} */
|
|
925
|
-
const moduleInstance = {
|
|
926
|
-
// Private state
|
|
927
|
-
_invokeQueue: invokeQueue,
|
|
928
|
-
_configBlocks: configBlocks,
|
|
929
|
-
_runBlocks: runBlocks,
|
|
930
|
-
|
|
931
|
-
/**
|
|
932
|
-
* @ngdoc method
|
|
933
|
-
* @name import('./types').Module#info
|
|
934
|
-
* @module ng
|
|
935
|
-
*
|
|
936
|
-
* @param {Object=} info Information about the module
|
|
937
|
-
* @returns {Object|import('./types').Module} The current info object for this module if called as a getter,
|
|
938
|
-
* or `this` if called as a setter.
|
|
939
|
-
*
|
|
940
|
-
* @description
|
|
941
|
-
* Read and write custom information about this module.
|
|
942
|
-
* For example you could put the version of the module in here.
|
|
943
|
-
*
|
|
944
|
-
* ```js
|
|
945
|
-
* angular.module('myModule', []).info({ version: '1.0.0' });
|
|
946
|
-
* ```
|
|
947
|
-
*
|
|
948
|
-
* The version could then be read back out by accessing the module elsewhere:
|
|
949
|
-
*
|
|
950
|
-
* ```
|
|
951
|
-
* let version = angular.module('myModule').info().version;
|
|
952
|
-
* ```
|
|
953
|
-
*
|
|
954
|
-
* You can also retrieve this information during runtime via the
|
|
955
|
-
* {@link $injector#modules `$injector.modules`} property:
|
|
956
|
-
*
|
|
957
|
-
* ```js
|
|
958
|
-
* let version = $injector.modules['myModule'].info().version;
|
|
959
|
-
* ```
|
|
960
|
-
*/
|
|
961
|
-
info(value) {
|
|
962
|
-
if (isDefined(value)) {
|
|
963
|
-
if (!isObject(value))
|
|
964
|
-
throw ngMinErr(
|
|
965
|
-
"aobj",
|
|
966
|
-
"Argument '{0}' must be an object",
|
|
967
|
-
"value",
|
|
968
|
-
);
|
|
969
|
-
info = value;
|
|
970
|
-
return this;
|
|
971
|
-
}
|
|
972
|
-
return info;
|
|
973
|
-
},
|
|
974
|
-
|
|
975
|
-
/**
|
|
976
|
-
* @ngdoc property
|
|
977
|
-
* @name import('./types').Module#requires
|
|
978
|
-
* @module ng
|
|
979
|
-
*
|
|
980
|
-
* @description
|
|
981
|
-
* Holds the list of modules which the injector will load before the current module is
|
|
982
|
-
* loaded.
|
|
983
|
-
*/
|
|
984
|
-
requires,
|
|
985
|
-
|
|
986
|
-
/**
|
|
987
|
-
* @ngdoc property
|
|
988
|
-
* @name import('./types').Module#name
|
|
989
|
-
* @module ng
|
|
990
|
-
*
|
|
991
|
-
* @description
|
|
992
|
-
* Name of the module.
|
|
993
|
-
*/
|
|
994
|
-
name,
|
|
995
|
-
|
|
996
|
-
/**
|
|
997
|
-
* @ngdoc method
|
|
998
|
-
* @name import('./types').Module#provider
|
|
999
|
-
* @module ng
|
|
1000
|
-
* @param {string} name service name
|
|
1001
|
-
* @param {Function} providerType Construction function for creating new instance of the
|
|
1002
|
-
* service.
|
|
1003
|
-
* @description
|
|
1004
|
-
* See {@link auto.$provide#provider $provide.provider()}.
|
|
1005
|
-
*/
|
|
1006
|
-
provider: invokeLaterAndSetModuleName("$provide", "provider"),
|
|
1007
|
-
|
|
1008
|
-
/**
|
|
1009
|
-
* @ngdoc method
|
|
1010
|
-
* @name import('./types').Module#factory
|
|
1011
|
-
* @module ng
|
|
1012
|
-
* @param {string} name service name
|
|
1013
|
-
* @param {Function} providerFunction Function for creating new instance of the service.
|
|
1014
|
-
* @description
|
|
1015
|
-
* See {@link auto.$provide#factory $provide.factory()}.
|
|
1016
|
-
*/
|
|
1017
|
-
factory: invokeLaterAndSetModuleName("$provide", "factory"),
|
|
1018
|
-
|
|
1019
|
-
/**
|
|
1020
|
-
* @ngdoc method
|
|
1021
|
-
* @name import('./types').Module#service
|
|
1022
|
-
* @module ng
|
|
1023
|
-
* @param {string} name service name
|
|
1024
|
-
* @param {Function} constructor A constructor function that will be instantiated.
|
|
1025
|
-
* @description
|
|
1026
|
-
* See {@link auto.$provide#service $provide.service()}.
|
|
1027
|
-
*/
|
|
1028
|
-
service: invokeLaterAndSetModuleName("$provide", "service"),
|
|
1029
|
-
|
|
1030
|
-
/**
|
|
1031
|
-
* @ngdoc method
|
|
1032
|
-
* @name import('./types').Module#value
|
|
1033
|
-
* @module ng
|
|
1034
|
-
* @param {string} name service name
|
|
1035
|
-
* @param {*} object Service instance object.
|
|
1036
|
-
* @description
|
|
1037
|
-
* See {@link auto.$provide#value $provide.value()}.
|
|
1038
|
-
*/
|
|
1039
|
-
value: invokeLater("$provide", "value"),
|
|
1040
|
-
|
|
1041
|
-
/**
|
|
1042
|
-
* @ngdoc method
|
|
1043
|
-
* @name import('./types').Module#constant
|
|
1044
|
-
* @module ng
|
|
1045
|
-
* @param {string} name constant name
|
|
1046
|
-
* @param {*} object Constant value.
|
|
1047
|
-
* @description
|
|
1048
|
-
* Because the constants are fixed, they get applied before other provide methods.
|
|
1049
|
-
* See {@link auto.$provide#constant $provide.constant()}.
|
|
1050
|
-
*/
|
|
1051
|
-
constant: invokeLater("$provide", "constant", "unshift"),
|
|
1052
|
-
|
|
1053
|
-
/**
|
|
1054
|
-
* @ngdoc method
|
|
1055
|
-
* @name import('./types').Module#decorator
|
|
1056
|
-
* @module ng
|
|
1057
|
-
* @param {string} name The name of the service to decorate.
|
|
1058
|
-
* @param {Function} decorFn This function will be invoked when the service needs to be
|
|
1059
|
-
* instantiated and should return the decorated service instance.
|
|
1060
|
-
* @description
|
|
1061
|
-
* See {@link auto.$provide#decorator $provide.decorator()}.
|
|
1062
|
-
*/
|
|
1063
|
-
decorator: invokeLaterAndSetModuleName(
|
|
1064
|
-
"$provide",
|
|
1065
|
-
"decorator",
|
|
1066
|
-
configBlocks,
|
|
1067
|
-
),
|
|
1068
|
-
|
|
1069
|
-
/**
|
|
1070
|
-
* @ngdoc method
|
|
1071
|
-
* @name import('./types').Module#animation
|
|
1072
|
-
* @module ng
|
|
1073
|
-
* @param {string} name animation name
|
|
1074
|
-
* @param {Function} animationFactory Factory function for creating new instance of an
|
|
1075
|
-
* animation.
|
|
1076
|
-
* @description
|
|
1077
|
-
*
|
|
1078
|
-
* **NOTE**: animations take effect only if the **ngAnimate** module is loaded.
|
|
1079
|
-
*
|
|
1080
|
-
*
|
|
1081
|
-
* Defines an animation hook that can be later used with
|
|
1082
|
-
* {@link $animate $animate} service and directives that use this service.
|
|
1083
|
-
*
|
|
1084
|
-
* ```js
|
|
1085
|
-
* module.animation('.animation-name', function($inject1, $inject2) {
|
|
1086
|
-
* return {
|
|
1087
|
-
* eventName : function(element, done) {
|
|
1088
|
-
* //code to run the animation
|
|
1089
|
-
* //once complete, then run done()
|
|
1090
|
-
* return function cancellationFunction(element) {
|
|
1091
|
-
* //code to cancel the animation
|
|
1092
|
-
* }
|
|
1093
|
-
* }
|
|
1094
|
-
* }
|
|
1095
|
-
* })
|
|
1096
|
-
* ```
|
|
1097
|
-
*
|
|
1098
|
-
* See {@link ng.$animateProvider#register $animateProvider.register()} and
|
|
1099
|
-
* {@link ngAnimate ngAnimate module} for more information.
|
|
1100
|
-
*/
|
|
1101
|
-
animation: invokeLaterAndSetModuleName(
|
|
1102
|
-
"$animateProvider",
|
|
1103
|
-
"register",
|
|
1104
|
-
),
|
|
1105
|
-
|
|
1106
|
-
/**
|
|
1107
|
-
* @ngdoc method
|
|
1108
|
-
* @name import('./types').Module#filter
|
|
1109
|
-
* @module ng
|
|
1110
|
-
* @param {string} name Filter name - this must be a valid AngularJS expression identifier
|
|
1111
|
-
* @param {Function} filterFactory Factory function for creating new instance of filter.
|
|
1112
|
-
* @description
|
|
1113
|
-
* See {@link ng.$filterProvider#register $filterProvider.register()}.
|
|
1114
|
-
*
|
|
1115
|
-
* <div class="alert alert-warning">
|
|
1116
|
-
* **Note:** Filter names must be valid AngularJS {@link expression} identifiers, such as `uppercase` or `orderBy`.
|
|
1117
|
-
* Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace
|
|
1118
|
-
* your filters, then you can use capitalization (`myappSubsectionFilterx`) or underscores
|
|
1119
|
-
* (`myapp_subsection_filterx`).
|
|
1120
|
-
* </div>
|
|
1121
|
-
*/
|
|
1122
|
-
filter: invokeLaterAndSetModuleName("$filterProvider", "register"),
|
|
1123
|
-
|
|
1124
|
-
/**
|
|
1125
|
-
* @ngdoc method
|
|
1126
|
-
* @name import('./types').Module#controller
|
|
1127
|
-
* @module ng
|
|
1128
|
-
* @param {string|Object} name Controller name, or an object map of controllers where the
|
|
1129
|
-
* keys are the names and the values are the constructors.
|
|
1130
|
-
* @param {Function} constructor Controller constructor function.
|
|
1131
|
-
* @description
|
|
1132
|
-
* See {@link ng.$controllerProvider#register $controllerProvider.register()}.
|
|
1133
|
-
*/
|
|
1134
|
-
controller: invokeLaterAndSetModuleName(
|
|
1135
|
-
"$controllerProvider",
|
|
1136
|
-
"register",
|
|
1137
|
-
),
|
|
1138
|
-
|
|
1139
|
-
/**
|
|
1140
|
-
* @ngdoc method
|
|
1141
|
-
* @name import('./types').Module#directive
|
|
1142
|
-
* @module ng
|
|
1143
|
-
* @param {string|Object} name Directive name, or an object map of directives where the
|
|
1144
|
-
* keys are the names and the values are the factories.
|
|
1145
|
-
* @param {Function} directiveFactory Factory function for creating new instance of
|
|
1146
|
-
* directives.
|
|
1147
|
-
* @description
|
|
1148
|
-
* See {@link ng.$compileProvider#directive $compileProvider.directive()}.
|
|
1149
|
-
*/
|
|
1150
|
-
directive: invokeLaterAndSetModuleName(
|
|
1151
|
-
"$compileProvider",
|
|
1152
|
-
"directive",
|
|
1153
|
-
),
|
|
1154
|
-
|
|
1155
|
-
/**
|
|
1156
|
-
* @ngdoc method
|
|
1157
|
-
* @name import('./types').Module#component
|
|
1158
|
-
* @module ng
|
|
1159
|
-
* @param {string|Object} name Name of the component in camelCase (i.e. `myComp` which will match `<my-comp>`),
|
|
1160
|
-
* or an object map of components where the keys are the names and the values are the component definition objects.
|
|
1161
|
-
* @param {Object} options Component definition object (a simplified
|
|
1162
|
-
* {@link ng.$compile#directive-definition-object directive definition object})
|
|
1163
|
-
*
|
|
1164
|
-
* @description
|
|
1165
|
-
* See {@link ng.$compileProvider#component $compileProvider.component()}.
|
|
1166
|
-
*/
|
|
1167
|
-
component: invokeLaterAndSetModuleName(
|
|
1168
|
-
"$compileProvider",
|
|
1169
|
-
"component",
|
|
1170
|
-
),
|
|
1171
|
-
|
|
1172
|
-
/**
|
|
1173
|
-
* @ngdoc method
|
|
1174
|
-
* @name import('./types').Module#config
|
|
1175
|
-
* @module ng
|
|
1176
|
-
* @param {Function} configFn Execute this function on module load. Useful for service
|
|
1177
|
-
* configuration.
|
|
1178
|
-
* @description
|
|
1179
|
-
* Use this method to configure services by injecting their
|
|
1180
|
-
* {@link import('./types').Module#provider `providers`}, e.g. for adding routes to the
|
|
1181
|
-
* {@link ngRoute.$routeProvider $routeProvider}.
|
|
1182
|
-
*
|
|
1183
|
-
* Note that you can only inject {@link import('./types').Module#provider `providers`} and
|
|
1184
|
-
* {@link import('./types').Module#constant `constants`} into this function.
|
|
1185
|
-
*
|
|
1186
|
-
* For more about how to configure services, see
|
|
1187
|
-
* {@link providers#provider-recipe Provider Recipe}.
|
|
1188
|
-
*/
|
|
1189
|
-
config,
|
|
1190
|
-
|
|
1191
|
-
/**
|
|
1192
|
-
* @ngdoc method
|
|
1193
|
-
* @name import('./types').Module#run
|
|
1194
|
-
* @module ng
|
|
1195
|
-
* @param {Function} initializationFn Execute this function after injector creation.
|
|
1196
|
-
* Useful for application initialization.
|
|
1197
|
-
* @description
|
|
1198
|
-
* Use this method to register work which should be performed when the injector is done
|
|
1199
|
-
* loading all modules.
|
|
1200
|
-
*/
|
|
1201
|
-
run(block) {
|
|
1202
|
-
runBlocks.push(block);
|
|
1203
|
-
return this;
|
|
1204
|
-
},
|
|
1205
|
-
};
|
|
1206
|
-
|
|
1207
|
-
if (configFn) {
|
|
1208
|
-
config(configFn);
|
|
1209
|
-
}
|
|
1210
|
-
|
|
1211
|
-
return moduleInstance;
|
|
1212
|
-
|
|
1213
|
-
/**
|
|
1214
|
-
* @param {string} provider
|
|
1215
|
-
* @param {string} method
|
|
1216
|
-
* @param {String=} insertMethod
|
|
1217
|
-
* @returns {import('./types').Module}
|
|
1218
|
-
*/
|
|
1219
|
-
function invokeLater(provider, method, insertMethod, queue) {
|
|
1220
|
-
if (!queue) queue = invokeQueue;
|
|
1221
|
-
return function () {
|
|
1222
|
-
queue[insertMethod || "push"]([provider, method, arguments]);
|
|
1223
|
-
return moduleInstance;
|
|
1224
|
-
};
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1227
|
-
/**
|
|
1228
|
-
* @param {string} provider
|
|
1229
|
-
* @param {string} method
|
|
1230
|
-
* @returns {import('./types').Module}
|
|
1231
|
-
*/
|
|
1232
|
-
function invokeLaterAndSetModuleName(provider, method, queue) {
|
|
1233
|
-
if (!queue) queue = invokeQueue;
|
|
1234
|
-
return function (recipeName, factoryFunction) {
|
|
1235
|
-
if (factoryFunction && isFunction(factoryFunction))
|
|
1236
|
-
factoryFunction.$$moduleName = name;
|
|
1237
|
-
queue.push([provider, method, arguments]);
|
|
1238
|
-
return moduleInstance;
|
|
1239
|
-
};
|
|
1240
|
-
}
|
|
1241
|
-
});
|
|
1242
|
-
};
|
|
1243
|
-
});
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
|
-
/**
|
|
1247
|
-
* @ngdoc function
|
|
1248
|
-
* @name angular.errorHandlingConfig
|
|
1249
|
-
* @module ng
|
|
1250
|
-
* @kind function
|
|
1251
|
-
*
|
|
1252
|
-
* @description
|
|
1253
|
-
* Configure several aspects of error handling in AngularJS if used as a setter or return the
|
|
1254
|
-
* current configuration if used as a getter. The following options are supported:
|
|
1255
|
-
*
|
|
1256
|
-
* - **objectMaxDepth**: The maximum depth to which objects are traversed when stringified for error messages.
|
|
1257
|
-
*
|
|
1258
|
-
* Omitted or undefined options will leave the corresponding configuration values unchanged.
|
|
1259
|
-
*
|
|
1260
|
-
* @param {Object=} config - The configuration object. May only contain the options that need to be
|
|
1261
|
-
* updated. Supported keys:
|
|
1262
|
-
*
|
|
1263
|
-
* * `objectMaxDepth` **{Number}** - The max depth for stringifying objects. Setting to a
|
|
1264
|
-
* non-positive or non-numeric value, removes the max depth limit.
|
|
1265
|
-
* Default: 5
|
|
1266
|
-
*
|
|
1267
|
-
* * `urlErrorParamsEnabled` **{Boolean}** - Specifies whether the generated error url will
|
|
1268
|
-
* contain the parameters of the thrown error. Disabling the parameters can be useful if the
|
|
1269
|
-
* generated error url is very long.
|
|
1270
|
-
*
|
|
1271
|
-
* Default: true. When used without argument, it returns the current value.
|
|
1272
|
-
*/
|
|
1273
|
-
export function errorHandlingConfig(config) {
|
|
1274
|
-
if (isObject(config)) {
|
|
1275
|
-
if (isDefined(config.objectMaxDepth)) {
|
|
1276
|
-
minErrConfig.objectMaxDepth = isValidObjectMaxDepth(config.objectMaxDepth)
|
|
1277
|
-
? config.objectMaxDepth
|
|
1278
|
-
: NaN;
|
|
1279
|
-
}
|
|
1280
|
-
if (
|
|
1281
|
-
isDefined(config.urlErrorParamsEnabled) &&
|
|
1282
|
-
isBoolean(config.urlErrorParamsEnabled)
|
|
1283
|
-
) {
|
|
1284
|
-
minErrConfig.urlErrorParamsEnabled = config.urlErrorParamsEnabled;
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1287
|
-
return minErrConfig;
|
|
293
|
+
function ensure(obj, name, factory) {
|
|
294
|
+
return obj[name] || (obj[name] = factory());
|
|
1288
295
|
}
|