@angular-wave/angular.ts 0.2.1 → 0.2.3
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/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 +1 -1
- package/src/animations/animate.spec.js +1 -1
- package/src/core/compile/attributes.js +1 -1
- package/src/core/compile/compile.js +10 -6
- package/src/core/compile/compile.spec.js +0 -6
- package/src/core/controller/controller.js +85 -131
- package/src/core/di/internal-injector.js +14 -14
- package/src/core/di/ng-module.js +2 -2
- package/src/core/filter/filter.md +1 -1
- package/src/core/location/location.spec.js +9 -9
- package/src/core/sanitize/sanitize-uri.spec.js +1 -1
- package/src/core/sce/sce.spec.js +3 -3
- package/src/core/scope/scope.spec.js +1 -1
- package/src/core/url-utils/url-utils.js +4 -4
- package/src/core/url-utils/url-utils.spec.js +1 -1
- package/src/directive/attrs/boolean.spec.js +1 -1
- package/src/directive/class/class.js +10 -90
- package/src/directive/class/class.md +90 -0
- package/src/directive/class/class.spec.js +1 -1
- package/src/directive/controller/controller.spec.js +0 -12
- package/src/directive/form/form.spec.js +3 -3
- package/src/directive/include/include.spec.js +1 -1
- package/src/directive/input/input.js +1 -1
- package/src/directive/model/model.js +50 -42
- package/src/directive/options/options.js +2 -2
- package/src/directive/repeat/repeat.spec.js +4 -4
- package/src/directive/select/select.js +1 -1
- package/src/directive/show-hide/show-hide.spec.js +1 -1
- package/src/directive/style/style.spec.js +1 -1
- package/src/directive/switch/switch.spec.js +1 -1
- package/src/directive/validators/validators.js +2 -2
- package/src/filters/filter.js +2 -3
- package/src/filters/limit-to.js +2 -2
- package/src/router/resolve/resolvable.js +4 -0
- package/src/router/resolve/resolve-context.js +12 -6
- package/src/router/state/state-builder.js +31 -23
- package/src/router/transition/hook-registry.js +2 -2
- package/src/router/transition/transition-hook.js +3 -3
- package/src/services/cookie-reader.js +1 -1
- package/src/services/http/http.js +24 -19
- package/src/shared/common.js +2 -2
- package/src/shared/common.spec.js +5 -7
- package/src/shared/hof.js +1 -2
- package/src/shared/jqlite/jqlite.js +26 -28
- package/src/shared/jqlite/jqlite.spec.js +10 -10
- package/src/shared/utils.js +6 -38
- package/types/core/controller/controller.d.ts +29 -5
- package/types/core/di/internal-injector.d.ts +6 -6
- package/types/core/di/ng-module.d.ts +2 -2
- package/types/directive/class/class.d.ts +3 -100
- package/types/directive/model/model.d.ts +6 -3
- package/types/directive/validators/validators.d.ts +2 -2
- package/types/router/resolve/resolve-context.d.ts +9 -6
- package/types/shared/common.d.ts +0 -2
- package/types/shared/hof.d.ts +0 -1
- package/types/shared/jqlite/jqlite.d.ts +4 -4
- package/types/shared/utils.d.ts +5 -13
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@angular-wave/angular.ts",
|
|
3
3
|
"description": "A modern, optimized and typesafe version of AngularJS",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.2.
|
|
5
|
+
"version": "0.2.3",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/angular-ts.esm.js",
|
|
8
8
|
"browser": "dist/angular-ts.umd.js",
|
package/src/angular.spec.js
CHANGED
|
@@ -1970,7 +1970,7 @@ describe("angular", () => {
|
|
|
1970
1970
|
describe("isElement", () => {
|
|
1971
1971
|
it("should return a boolean value", () => {
|
|
1972
1972
|
const element = $compile("<p>Hello, world!</p>")($rootScope);
|
|
1973
|
-
const body =
|
|
1973
|
+
const body = document.body;
|
|
1974
1974
|
const expected = [
|
|
1975
1975
|
false,
|
|
1976
1976
|
false,
|
|
@@ -6,7 +6,7 @@ import { createInjector } from "../di/injector";
|
|
|
6
6
|
|
|
7
7
|
describe("$animate", () => {
|
|
8
8
|
describe("without animation", () => {
|
|
9
|
-
let dummy =
|
|
9
|
+
let dummy = document.getElementById("dummy");
|
|
10
10
|
let element;
|
|
11
11
|
let $compile;
|
|
12
12
|
let $rootElement;
|
|
@@ -13,7 +13,7 @@ import { ALIASED_ATTR } from "../../shared/constants";
|
|
|
13
13
|
|
|
14
14
|
const $compileMinErr = minErr("$compile");
|
|
15
15
|
const SIMPLE_ATTR_NAME = /^\w/;
|
|
16
|
-
const specialAttrHolder =
|
|
16
|
+
const specialAttrHolder = document.createElement("div");
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* @typedef {Object} AttributeLike
|
|
@@ -1679,7 +1679,7 @@ export function $CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
1679
1679
|
} else {
|
|
1680
1680
|
// We have transclusion slots,
|
|
1681
1681
|
// collect them up, compile them and store their transclusion functions
|
|
1682
|
-
$template =
|
|
1682
|
+
$template = document.createDocumentFragment();
|
|
1683
1683
|
|
|
1684
1684
|
const slotMap = Object.create(null);
|
|
1685
1685
|
const filledSlots = Object.create(null);
|
|
@@ -1712,8 +1712,7 @@ export function $CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
1712
1712
|
if (slotName) {
|
|
1713
1713
|
filledSlots[slotName] = true;
|
|
1714
1714
|
slots[slotName] =
|
|
1715
|
-
slots[slotName] ||
|
|
1716
|
-
window.document.createDocumentFragment();
|
|
1715
|
+
slots[slotName] || document.createDocumentFragment();
|
|
1717
1716
|
slots[slotName].appendChild(node);
|
|
1718
1717
|
} else {
|
|
1719
1718
|
$template.appendChild(node);
|
|
@@ -2462,12 +2461,17 @@ export function $CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
2462
2461
|
}
|
|
2463
2462
|
}
|
|
2464
2463
|
|
|
2464
|
+
/**
|
|
2465
|
+
* @param {string} type
|
|
2466
|
+
* @param {string} template
|
|
2467
|
+
* @returns
|
|
2468
|
+
*/
|
|
2465
2469
|
function wrapTemplate(type, template) {
|
|
2466
|
-
type =
|
|
2470
|
+
type = (type || "html").toLowerCase();
|
|
2467
2471
|
switch (type) {
|
|
2468
2472
|
case "svg":
|
|
2469
2473
|
case "math":
|
|
2470
|
-
var wrapper =
|
|
2474
|
+
var wrapper = document.createElement("div");
|
|
2471
2475
|
wrapper.innerHTML = `<${type}>${template}</${type}>`;
|
|
2472
2476
|
return wrapper.childNodes[0].childNodes;
|
|
2473
2477
|
default:
|
|
@@ -2775,7 +2779,7 @@ export function $CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
2775
2779
|
// - remove them from the DOM
|
|
2776
2780
|
// - allow them to still be traversed with .nextSibling
|
|
2777
2781
|
// - allow a single fragment.qSA to fetch all elements being removed
|
|
2778
|
-
const fragment =
|
|
2782
|
+
const fragment = document.createDocumentFragment();
|
|
2779
2783
|
for (i = 0; i < removeCount; i++) {
|
|
2780
2784
|
fragment.appendChild(elementsToRemove[i]);
|
|
2781
2785
|
}
|
|
@@ -25,12 +25,6 @@ function isHTMLElement(el) {
|
|
|
25
25
|
return !!el.toString().match(/HTML/);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
function supportsMathML() {
|
|
29
|
-
const d = document.createElement("div");
|
|
30
|
-
d.innerHTML = "<math></math>";
|
|
31
|
-
return !isUnknownElement(d.firstChild);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
28
|
function getChildScopes(scope) {
|
|
35
29
|
let children = [];
|
|
36
30
|
if (!scope.$$childHead) {
|
|
@@ -2,10 +2,8 @@ import {
|
|
|
2
2
|
assertArgFn,
|
|
3
3
|
assertNotHasOwnProperty,
|
|
4
4
|
minErr,
|
|
5
|
-
extend,
|
|
6
5
|
isObject,
|
|
7
6
|
isString,
|
|
8
|
-
getter,
|
|
9
7
|
isFunction,
|
|
10
8
|
} from "../../shared/utils";
|
|
11
9
|
|
|
@@ -27,98 +25,72 @@ export function identifierForController(controller, ident) {
|
|
|
27
25
|
* This provider allows controller registration via the
|
|
28
26
|
* {@link ng.$controllerProvider#register register} method.
|
|
29
27
|
*/
|
|
30
|
-
export
|
|
31
|
-
|
|
28
|
+
export class $ControllerProvider {
|
|
29
|
+
constructor() {
|
|
30
|
+
/**
|
|
31
|
+
* @type {Map<string, Function|Object>}
|
|
32
|
+
* @private
|
|
33
|
+
*/
|
|
34
|
+
this.controllers = new Map();
|
|
35
|
+
}
|
|
32
36
|
|
|
33
37
|
/**
|
|
38
|
+
* Check if a controller with a given name exists.
|
|
39
|
+
*
|
|
34
40
|
* @param {string} name Controller name to check.
|
|
41
|
+
* @returns {boolean} True if the controller exists, false otherwise.
|
|
35
42
|
*/
|
|
36
|
-
|
|
37
|
-
return
|
|
38
|
-
}
|
|
43
|
+
has(name) {
|
|
44
|
+
return this.controllers.has(name);
|
|
45
|
+
}
|
|
39
46
|
|
|
40
47
|
/**
|
|
48
|
+
* Register a controller.
|
|
49
|
+
*
|
|
41
50
|
* @param {string|Object} name Controller name, or an object map of controllers where the keys are
|
|
42
51
|
* the names and the values are the constructors.
|
|
43
|
-
* @param {Function|Array} constructor Controller constructor
|
|
52
|
+
* @param {Function|Array} constructor Controller constructor function (optionally decorated with DI
|
|
44
53
|
* annotations in the array notation).
|
|
45
54
|
*/
|
|
46
|
-
|
|
55
|
+
register(name, constructor) {
|
|
47
56
|
assertNotHasOwnProperty(name, "controller");
|
|
48
57
|
if (isObject(name)) {
|
|
49
|
-
|
|
58
|
+
Object.entries(name).forEach(([key, value]) => {
|
|
59
|
+
this.controllers.set(key, value);
|
|
60
|
+
});
|
|
50
61
|
} else {
|
|
51
|
-
controllers
|
|
62
|
+
this.controllers.set(name, constructor);
|
|
52
63
|
}
|
|
53
|
-
}
|
|
64
|
+
}
|
|
54
65
|
|
|
55
|
-
|
|
66
|
+
/**
|
|
67
|
+
* $get method for dependency injection.
|
|
68
|
+
*
|
|
69
|
+
* @param {import("../../core/di/internal-injector").InjectorService} $injector
|
|
70
|
+
* @returns {Function} A service function that creates controllers.
|
|
71
|
+
*/
|
|
72
|
+
$get = [
|
|
56
73
|
"$injector",
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
* @param {import("../../core/di/internal-injector").InjectorService} $injector
|
|
60
|
-
* @returns
|
|
61
|
-
*/
|
|
62
|
-
function ($injector) {
|
|
63
|
-
/**
|
|
64
|
-
* @param {Function|string} expression If called with a function then it's considered to be the
|
|
65
|
-
* controller constructor function. Otherwise it's considered to be a string which is used
|
|
66
|
-
* to retrieve the controller constructor using the following steps:
|
|
67
|
-
*
|
|
68
|
-
* * check if a controller with given name is registered via `$controllerProvider`
|
|
69
|
-
* * check if evaluating the string on the current scope returns a constructor
|
|
70
|
-
*
|
|
71
|
-
* The string can use the `controller as property` syntax, where the controller instance is published
|
|
72
|
-
* as the specified property on the `scope`; the `scope` must be injected into `locals` param for this
|
|
73
|
-
* to work correctly.
|
|
74
|
-
*
|
|
75
|
-
* @param {Object} locals Injection locals for Controller.
|
|
76
|
-
* @return {Object} Instance of given controller.
|
|
77
|
-
*
|
|
78
|
-
* @description
|
|
79
|
-
* `$controller` service is responsible for instantiating controllers.
|
|
80
|
-
*
|
|
81
|
-
* It's just a simple call to {@link auto.$injector $injector}, but extracted into
|
|
82
|
-
* a service, so that one can override this service with [BC version](https://gist.github.com/1649788).
|
|
83
|
-
*/
|
|
84
|
-
return function $controller(expression, locals, later, ident) {
|
|
85
|
-
// PRIVATE API:
|
|
86
|
-
// param `later` --- indicates that the controller's constructor is invoked at a later time.
|
|
87
|
-
// If true, $controller will allocate the object with the correct
|
|
88
|
-
// prototype chain, but will not invoke the controller until a returned
|
|
89
|
-
// callback is invoked.
|
|
90
|
-
// param `ident` --- An optional label which overrides the label parsed from the controller
|
|
91
|
-
// expression, if any.
|
|
74
|
+
($injector) => {
|
|
75
|
+
return (expression, locals, later, ident) => {
|
|
92
76
|
let instance;
|
|
93
|
-
|
|
94
|
-
/** @type { RegExpMatchArray | null} */
|
|
95
77
|
let match;
|
|
96
|
-
|
|
97
78
|
let constructor;
|
|
98
|
-
let identifier;
|
|
79
|
+
let identifier = ident && isString(ident) ? ident : null;
|
|
99
80
|
later = later === true;
|
|
100
|
-
if (ident && isString(ident)) {
|
|
101
|
-
identifier = ident;
|
|
102
|
-
}
|
|
103
81
|
|
|
104
82
|
if (isString(expression)) {
|
|
105
|
-
match =
|
|
83
|
+
match = expression.match(CNTRL_REG);
|
|
106
84
|
if (!match) {
|
|
107
85
|
throw $controllerMinErr(
|
|
108
86
|
"ctrlfmt",
|
|
109
|
-
"Badly formed controller string '{0}'. "
|
|
110
|
-
"Must match `__name__ as __id__` or `__name__`.",
|
|
87
|
+
"Badly formed controller string '{0}'. Must match `__name__ as __id__` or `__name__`.",
|
|
111
88
|
expression,
|
|
112
89
|
);
|
|
113
90
|
}
|
|
114
91
|
constructor = match[1];
|
|
115
92
|
identifier = identifier || match[3];
|
|
116
|
-
expression =
|
|
117
|
-
controllers,
|
|
118
|
-
constructor,
|
|
119
|
-
)
|
|
120
|
-
? controllers[constructor]
|
|
121
|
-
: getter(locals.$scope, constructor, true);
|
|
93
|
+
expression = this.controllers.get(constructor);
|
|
122
94
|
|
|
123
95
|
if (!expression) {
|
|
124
96
|
throw $controllerMinErr(
|
|
@@ -132,16 +104,6 @@ export function $ControllerProvider() {
|
|
|
132
104
|
}
|
|
133
105
|
|
|
134
106
|
if (later) {
|
|
135
|
-
// Instantiate controller later:
|
|
136
|
-
// This machinery is used to create an instance of the object before calling the
|
|
137
|
-
// controller's constructor itself.
|
|
138
|
-
//
|
|
139
|
-
// This allows properties to be added to the controller before the constructor is
|
|
140
|
-
// invoked. Primarily, this is used for isolate scope bindings in $compile.
|
|
141
|
-
//
|
|
142
|
-
// This feature is not intended for use by applications, and is thus not documented
|
|
143
|
-
// publicly.
|
|
144
|
-
// Object creation: http://jsperf.com/create-constructor/2
|
|
145
107
|
const controllerPrototype = (
|
|
146
108
|
Array.isArray(expression)
|
|
147
109
|
? expression[expression.length - 1]
|
|
@@ -150,82 +112,74 @@ export function $ControllerProvider() {
|
|
|
150
112
|
instance = Object.create(controllerPrototype || null);
|
|
151
113
|
|
|
152
114
|
if (identifier) {
|
|
153
|
-
addIdentifier(
|
|
115
|
+
this.addIdentifier(
|
|
154
116
|
locals,
|
|
155
117
|
identifier,
|
|
156
118
|
instance,
|
|
157
|
-
constructor ||
|
|
158
|
-
/** @type {import("../../types").Controller} */ (expression)
|
|
159
|
-
.name,
|
|
119
|
+
constructor || expression.name,
|
|
160
120
|
);
|
|
161
121
|
}
|
|
162
122
|
|
|
163
|
-
return
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
expression,
|
|
167
|
-
instance,
|
|
168
|
-
locals,
|
|
169
|
-
constructor,
|
|
170
|
-
);
|
|
171
|
-
if (
|
|
172
|
-
result !== instance &&
|
|
173
|
-
(isObject(result) || isFunction(result))
|
|
174
|
-
) {
|
|
175
|
-
instance = result;
|
|
176
|
-
if (identifier) {
|
|
177
|
-
// If result changed, re-assign controllerAs value to scope.
|
|
178
|
-
addIdentifier(
|
|
179
|
-
locals,
|
|
180
|
-
identifier,
|
|
181
|
-
instance,
|
|
182
|
-
constructor ||
|
|
183
|
-
/** @type {import("../../types").Controller} */ (
|
|
184
|
-
expression
|
|
185
|
-
).name,
|
|
186
|
-
);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return instance;
|
|
190
|
-
},
|
|
191
|
-
{
|
|
123
|
+
return function () {
|
|
124
|
+
const result = $injector.invoke(
|
|
125
|
+
expression,
|
|
192
126
|
instance,
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
127
|
+
locals,
|
|
128
|
+
constructor,
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
if (
|
|
132
|
+
result !== instance &&
|
|
133
|
+
(isObject(result) || isFunction(result))
|
|
134
|
+
) {
|
|
135
|
+
instance = result;
|
|
136
|
+
if (identifier) {
|
|
137
|
+
this.addIdentifier(
|
|
138
|
+
locals,
|
|
139
|
+
identifier,
|
|
140
|
+
instance,
|
|
141
|
+
constructor || expression.name,
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return instance;
|
|
147
|
+
}.bind(this, { instance, identifier });
|
|
196
148
|
}
|
|
197
149
|
|
|
198
|
-
instance = $injector.instantiate(
|
|
199
|
-
/** @type {Function} */ (expression),
|
|
200
|
-
locals,
|
|
201
|
-
constructor,
|
|
202
|
-
);
|
|
150
|
+
instance = $injector.instantiate(expression, locals, constructor);
|
|
203
151
|
|
|
204
152
|
if (identifier) {
|
|
205
|
-
addIdentifier(
|
|
153
|
+
this.addIdentifier(
|
|
206
154
|
locals,
|
|
207
155
|
identifier,
|
|
208
156
|
instance,
|
|
209
|
-
constructor ||
|
|
210
|
-
/** @type {import("../../types").Controller} */ (expression).name,
|
|
157
|
+
constructor || expression.name,
|
|
211
158
|
);
|
|
212
159
|
}
|
|
213
160
|
|
|
214
161
|
return instance;
|
|
215
162
|
};
|
|
216
|
-
|
|
217
|
-
function addIdentifier(locals, identifier, instance, name) {
|
|
218
|
-
if (!(locals && isObject(locals.$scope))) {
|
|
219
|
-
throw minErr("$controller")(
|
|
220
|
-
"noscp",
|
|
221
|
-
"Cannot export controller '{0}' as '{1}'! No $scope object provided via `locals`.",
|
|
222
|
-
name,
|
|
223
|
-
identifier,
|
|
224
|
-
);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
locals.$scope[identifier] = instance;
|
|
228
|
-
}
|
|
229
163
|
},
|
|
230
164
|
];
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Adds an identifier to the controller instance in the given locals' scope.
|
|
168
|
+
*
|
|
169
|
+
* @param {Object} locals The locals object containing the scope.
|
|
170
|
+
* @param {string} identifier The identifier to assign.
|
|
171
|
+
* @param {Object} instance The controller instance.
|
|
172
|
+
* @param {string} name The name of the controller.
|
|
173
|
+
*/
|
|
174
|
+
addIdentifier(locals, identifier, instance, name) {
|
|
175
|
+
if (!(locals && isObject(locals.$scope))) {
|
|
176
|
+
throw minErr("$controller")(
|
|
177
|
+
"noscp",
|
|
178
|
+
"Cannot export controller '{0}' as '{1}'! No $scope object provided via `locals`.",
|
|
179
|
+
name,
|
|
180
|
+
identifier,
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
locals.$scope[identifier] = instance;
|
|
184
|
+
}
|
|
231
185
|
}
|
|
@@ -30,7 +30,7 @@ class AbstractInjector {
|
|
|
30
30
|
/**
|
|
31
31
|
* Get a service by name.
|
|
32
32
|
*
|
|
33
|
-
* @param {
|
|
33
|
+
* @param {string} serviceName
|
|
34
34
|
* @returns {any}
|
|
35
35
|
*/
|
|
36
36
|
get(serviceName) {
|
|
@@ -63,7 +63,7 @@ class AbstractInjector {
|
|
|
63
63
|
*
|
|
64
64
|
* @param {Function|Array} fn
|
|
65
65
|
* @param {Object} locals
|
|
66
|
-
* @param {
|
|
66
|
+
* @param {string} serviceName
|
|
67
67
|
* @returns
|
|
68
68
|
*/
|
|
69
69
|
injectionArgs(fn, locals, serviceName) {
|
|
@@ -94,7 +94,7 @@ class AbstractInjector {
|
|
|
94
94
|
* @param {Function|String|Array<any>} fn
|
|
95
95
|
* @param {*} [self]
|
|
96
96
|
* @param {Object} [locals]
|
|
97
|
-
* @param {
|
|
97
|
+
* @param {string} [serviceName]
|
|
98
98
|
* @returns
|
|
99
99
|
*/
|
|
100
100
|
invoke(fn, self, locals, serviceName) {
|
|
@@ -112,7 +112,7 @@ class AbstractInjector {
|
|
|
112
112
|
fn = fn[fn.length - 1];
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
if (isClass(/** @type {
|
|
115
|
+
if (isClass(/** @type {string} */ (fn))) {
|
|
116
116
|
args.unshift(null);
|
|
117
117
|
return new (Function.prototype.bind.apply(fn, args))();
|
|
118
118
|
} else {
|
|
@@ -124,7 +124,7 @@ class AbstractInjector {
|
|
|
124
124
|
* Instantiate a type constructor with optional locals.
|
|
125
125
|
* @param {Function|Array} type
|
|
126
126
|
* @param {*} [locals]
|
|
127
|
-
* @param {
|
|
127
|
+
* @param {string} [serviceName]
|
|
128
128
|
*/
|
|
129
129
|
instantiate(type, locals, serviceName) {
|
|
130
130
|
// Check if type is annotated and use just the given function at n-1 as parameter
|
|
@@ -143,7 +143,7 @@ class AbstractInjector {
|
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
145
|
* @abstract
|
|
146
|
-
* @param {
|
|
146
|
+
* @param {string} _serviceName
|
|
147
147
|
*/
|
|
148
148
|
factory(_serviceName) {
|
|
149
149
|
console.error(`Unhandled ${_serviceName}`);
|
|
@@ -166,7 +166,7 @@ export class ProviderInjector extends AbstractInjector {
|
|
|
166
166
|
|
|
167
167
|
/**
|
|
168
168
|
* Factory method for creating services.
|
|
169
|
-
* @param {
|
|
169
|
+
* @param {string} caller - The name of the caller requesting the service.
|
|
170
170
|
* @throws {Error} If the provider is unknown.
|
|
171
171
|
*/
|
|
172
172
|
factory(caller) {
|
|
@@ -204,7 +204,7 @@ export class InjectorService extends AbstractInjector {
|
|
|
204
204
|
|
|
205
205
|
/**
|
|
206
206
|
*
|
|
207
|
-
* @param {
|
|
207
|
+
* @param {string} name
|
|
208
208
|
* @returns {boolean}
|
|
209
209
|
*/
|
|
210
210
|
has(name) {
|
|
@@ -220,15 +220,15 @@ export class InjectorService extends AbstractInjector {
|
|
|
220
220
|
// Helpers
|
|
221
221
|
|
|
222
222
|
/**
|
|
223
|
-
* @param {
|
|
224
|
-
* @returns {
|
|
223
|
+
* @param {string} fn
|
|
224
|
+
* @returns {string}
|
|
225
225
|
*/
|
|
226
226
|
function stringifyFn(fn) {
|
|
227
227
|
return Function.prototype.toString.call(fn);
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
/**
|
|
231
|
-
* @param {
|
|
231
|
+
* @param {string} fn
|
|
232
232
|
* @returns {Array<any>}
|
|
233
233
|
*/
|
|
234
234
|
function extractArgs(fn) {
|
|
@@ -238,7 +238,7 @@ function extractArgs(fn) {
|
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
/**
|
|
241
|
-
* @param {
|
|
241
|
+
* @param {string} func
|
|
242
242
|
* @returns {boolean}
|
|
243
243
|
*/
|
|
244
244
|
function isClass(func) {
|
|
@@ -249,7 +249,7 @@ function isClass(func) {
|
|
|
249
249
|
*
|
|
250
250
|
* @param {any} fn
|
|
251
251
|
* @param {boolean} strictDi
|
|
252
|
-
* @param {
|
|
252
|
+
* @param {string} name
|
|
253
253
|
* @returns {Array<string>}
|
|
254
254
|
*/
|
|
255
255
|
function annotate(fn, strictDi, name) {
|
|
@@ -266,7 +266,7 @@ function annotate(fn, strictDi, name) {
|
|
|
266
266
|
name,
|
|
267
267
|
);
|
|
268
268
|
}
|
|
269
|
-
argDecl = extractArgs(/** @type {
|
|
269
|
+
argDecl = extractArgs(/** @type {string} */ (fn));
|
|
270
270
|
argDecl[1].split(FN_ARG_SPLIT).forEach(function (arg) {
|
|
271
271
|
arg.replace(FN_ARG, function (_all, _underscore, name) {
|
|
272
272
|
$inject.push(name);
|
package/src/core/di/ng-module.js
CHANGED
|
@@ -25,8 +25,8 @@ export const CONTROLLER_LITERAL = "$controllerProvider";
|
|
|
25
25
|
*/
|
|
26
26
|
export class NgModule {
|
|
27
27
|
/**
|
|
28
|
-
* @param {
|
|
29
|
-
* @param {Array<
|
|
28
|
+
* @param {string} name - Name of the module
|
|
29
|
+
* @param {Array<string>} requires - List of modules which the injector will load before the current module
|
|
30
30
|
* @param {Function} [configFn]
|
|
31
31
|
*/
|
|
32
32
|
constructor(name, requires, configFn) {
|
|
@@ -1796,7 +1796,7 @@ describe("$location", () => {
|
|
|
1796
1796
|
|
|
1797
1797
|
// afterEach(() => {
|
|
1798
1798
|
// dealoc(root);
|
|
1799
|
-
// dealoc(
|
|
1799
|
+
// dealoc(document.body);
|
|
1800
1800
|
// });
|
|
1801
1801
|
|
|
1802
1802
|
// it("should rewrite rel link to new url when history enabled on new browser", () => {
|
|
@@ -2303,7 +2303,7 @@ describe("$location", () => {
|
|
|
2303
2303
|
// }),
|
|
2304
2304
|
// setupRewriteChecks(),
|
|
2305
2305
|
// ($browser) => {
|
|
2306
|
-
// const rightClick =
|
|
2306
|
+
// const rightClick = document.createEvent("MouseEvents");
|
|
2307
2307
|
// rightClick.initMouseEvent(
|
|
2308
2308
|
// "click",
|
|
2309
2309
|
// true,
|
|
@@ -2441,12 +2441,12 @@ describe("$location", () => {
|
|
|
2441
2441
|
// });
|
|
2442
2442
|
// inject(($location) => {
|
|
2443
2443
|
// // make IE happy
|
|
2444
|
-
// JQLite(
|
|
2444
|
+
// JQLite(document.body).html(
|
|
2445
2445
|
// '<a href="http://server/test.html">link</a>',
|
|
2446
2446
|
// );
|
|
2447
2447
|
|
|
2448
2448
|
// const event = {
|
|
2449
|
-
// target: JQLite(
|
|
2449
|
+
// target: JQLite(document.body).find("a")[0],
|
|
2450
2450
|
// preventDefault: jasmine.createSpy("preventDefault"),
|
|
2451
2451
|
// isDefaultPrevented: jasmine.createSpy().and.returnValue(false),
|
|
2452
2452
|
// };
|
|
@@ -2481,12 +2481,12 @@ describe("$location", () => {
|
|
|
2481
2481
|
// $location,
|
|
2482
2482
|
// ) => {
|
|
2483
2483
|
// // make IE happy
|
|
2484
|
-
// JQLite(
|
|
2484
|
+
// JQLite(document.body).html(
|
|
2485
2485
|
// '<a href="http://server/index.html#test">link</a>',
|
|
2486
2486
|
// );
|
|
2487
2487
|
|
|
2488
2488
|
// const event = {
|
|
2489
|
-
// target: JQLite(
|
|
2489
|
+
// target: JQLite(document.body).find("a")[0],
|
|
2490
2490
|
// preventDefault: jasmine.createSpy("preventDefault"),
|
|
2491
2491
|
// isDefaultPrevented: jasmine.createSpy().and.returnValue(false),
|
|
2492
2492
|
// };
|
|
@@ -2920,7 +2920,7 @@ describe("$location", () => {
|
|
|
2920
2920
|
// function ($rootElement, $compile, $rootScope) {
|
|
2921
2921
|
// $rootElement.html('<a href="http://server/#!/somePath">link</a>');
|
|
2922
2922
|
// $compile($rootElement)($rootScope);
|
|
2923
|
-
// JQLite(
|
|
2923
|
+
// JQLite(document.body).append($rootElement);
|
|
2924
2924
|
// },
|
|
2925
2925
|
// );
|
|
2926
2926
|
|
|
@@ -2951,7 +2951,7 @@ describe("$location", () => {
|
|
|
2951
2951
|
// return function ($rootElement, $compile, $rootScope) {
|
|
2952
2952
|
// $rootElement.html('<a href="http://server/somePath">link</a>');
|
|
2953
2953
|
// $compile($rootElement)($rootScope);
|
|
2954
|
-
// JQLite(
|
|
2954
|
+
// JQLite(document.body).append($rootElement);
|
|
2955
2955
|
// };
|
|
2956
2956
|
// });
|
|
2957
2957
|
|
|
@@ -3313,7 +3313,7 @@ describe("$location", () => {
|
|
|
3313
3313
|
// function mockUpBrowser(options) {
|
|
3314
3314
|
// module(($windowProvider, $browserProvider) => {
|
|
3315
3315
|
// let browser;
|
|
3316
|
-
// const parser =
|
|
3316
|
+
// const parser = document.createElement("a");
|
|
3317
3317
|
// parser.href = options.initialUrl;
|
|
3318
3318
|
|
|
3319
3319
|
// $windowProvider.$get = function () {
|
package/src/core/sce/sce.spec.js
CHANGED
|
@@ -522,16 +522,16 @@ describe("SCE", () => {
|
|
|
522
522
|
|
|
523
523
|
let baseElem;
|
|
524
524
|
beforeEach(() => {
|
|
525
|
-
baseElem =
|
|
525
|
+
baseElem = document.createElement("BASE");
|
|
526
526
|
baseElem.setAttribute(
|
|
527
527
|
"href",
|
|
528
528
|
`${window.location.protocol}//foo.example.com/path/`,
|
|
529
529
|
);
|
|
530
|
-
|
|
530
|
+
document.head.appendChild(baseElem);
|
|
531
531
|
});
|
|
532
532
|
|
|
533
533
|
afterEach(() => {
|
|
534
|
-
|
|
534
|
+
document.head.removeChild(baseElem);
|
|
535
535
|
});
|
|
536
536
|
|
|
537
537
|
it("should allow relative URLs", () => {
|
|
@@ -1095,7 +1095,7 @@ describe("Scope", function () {
|
|
|
1095
1095
|
|
|
1096
1096
|
it("should watch array-like objects like arrays", () => {
|
|
1097
1097
|
logs = [];
|
|
1098
|
-
$rootScope.obj =
|
|
1098
|
+
$rootScope.obj = document.getElementsByTagName("src");
|
|
1099
1099
|
$rootScope.$digest();
|
|
1100
1100
|
|
|
1101
1101
|
expect(logs.length).toBeTruthy();
|
|
@@ -5,7 +5,7 @@ import { isString } from "../../shared/utils";
|
|
|
5
5
|
* @typedef {"http"|"https"} HttpProtocol
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
const urlParsingNode =
|
|
8
|
+
const urlParsingNode = document.createElement("a");
|
|
9
9
|
const originUrl = urlResolve(window.location.href);
|
|
10
10
|
let baseUrlParsingNode;
|
|
11
11
|
|
|
@@ -126,13 +126,13 @@ export function urlsAreSameOrigin(url1, url2) {
|
|
|
126
126
|
* @returns {string}
|
|
127
127
|
*/
|
|
128
128
|
export function getBaseUrl() {
|
|
129
|
-
if (
|
|
130
|
-
return
|
|
129
|
+
if (document.baseURI) {
|
|
130
|
+
return document.baseURI;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
// `document.baseURI` is available everywhere except IE
|
|
134
134
|
if (!baseUrlParsingNode) {
|
|
135
|
-
baseUrlParsingNode =
|
|
135
|
+
baseUrlParsingNode = document.createElement("a");
|
|
136
136
|
baseUrlParsingNode.href = ".";
|
|
137
137
|
|
|
138
138
|
// Work-around for IE bug described in Implementation Notes. The fix in `urlResolve()` is not
|