@angular-wave/angular.ts 0.0.47 → 0.0.48
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 -2
- package/src/animations/animate-queue.js +0 -1
- package/src/animations/animation.js +1 -1
- package/src/animations/raf-scheduler.js +0 -1
- package/src/animations/shared.js +1 -1
- package/src/core/animate/animate.js +0 -1
- package/src/core/compile/compile.spec.js +1 -1
- package/src/core/location/location.spec.js +1 -1
- package/src/core/parser/ast-type.js +22 -0
- package/src/core/parser/ast.js +422 -0
- package/src/core/parser/compiler.js +561 -0
- package/src/core/parser/interpreter.js +422 -0
- package/src/core/parser/lexer.js +257 -0
- package/src/core/parser/parse.js +9 -1930
- package/src/core/parser/parse.spec.js +2 -2
- package/src/core/parser/parser.js +39 -0
- package/src/core/parser/shared.js +228 -0
- package/src/core/q/q.spec.js +0 -1
- package/src/core/sce/sce.js +3 -6
- package/src/core/scope/scope.js +19 -11
- package/src/core/task-tracker-factory.js +0 -1
- package/src/directive/class/class.js +0 -2
- package/src/directive/form/form.js +0 -3
- package/src/directive/include/include.js +1 -1
- package/src/directive/include/include.spec.js +0 -1
- package/src/directive/input/input.js +1 -2
- package/src/directive/model/model.js +1 -3
- package/src/directive/model/model.spec.js +0 -1
- package/src/directive/repeat/repeat.spec.js +0 -2
- package/src/exts/aria/aria.js +0 -1
- package/src/filters/filter.spec.js +0 -1
- package/src/injector.js +1 -1
- package/src/injector.spec.js +0 -5
- package/src/loader.js +0 -5
- package/src/services/cookie-reader.js +0 -1
- package/src/services/http/http.spec.js +0 -2
- package/src/shared/utils.js +18 -7
- package/src/types.js +10 -0
- package/types/core/parser/ast-type.d.ts +20 -0
- package/types/core/parser/ast.d.ts +78 -0
- package/types/core/parser/compiler.d.ts +49 -0
- package/types/core/parser/interpreter.d.ts +57 -0
- package/types/core/parser/parse.d.ts +79 -0
- package/types/core/parser/parser.d.ts +22 -0
- package/types/core/parser/shared.d.ts +29 -0
- package/types/core/scope/scope.d.ts +9 -2
- package/types/shared/utils.d.ts +18 -5
- package/types/types.d.ts +1 -0
- package/types-back/index.d.ts +0 -12
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { AST
|
|
1
|
+
import { AST } from "./ast";
|
|
2
|
+
import { Lexer } from "./lexer";
|
|
2
3
|
import {
|
|
3
4
|
forEach,
|
|
4
5
|
isFunction,
|
|
@@ -2366,7 +2367,6 @@ describe("parser", () => {
|
|
|
2366
2367
|
|
|
2367
2368
|
it("should evaluate negation", () => {
|
|
2368
2369
|
expect(scope.$eval("!false || true")).toEqual(!false || true);
|
|
2369
|
-
// eslint-disable-next-line eqeqeq
|
|
2370
2370
|
expect(scope.$eval("!11 == 10")).toEqual(!11 == 10);
|
|
2371
2371
|
expect(scope.$eval("12/6/2")).toEqual(12 / 6 / 2);
|
|
2372
2372
|
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { AST } from "./ast";
|
|
2
|
+
import { isLiteral, isConstant } from "./shared";
|
|
3
|
+
import { ASTInterpreter } from "./interpreter";
|
|
4
|
+
import { ASTCompiler } from "./compiler";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @constructor
|
|
8
|
+
*/
|
|
9
|
+
export class Parser {
|
|
10
|
+
constructor(lexer, $filter, options) {
|
|
11
|
+
this.ast = new AST(lexer, options);
|
|
12
|
+
this.astCompiler = options.csp
|
|
13
|
+
? new ASTInterpreter($filter)
|
|
14
|
+
: new ASTCompiler($filter);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
parse(text) {
|
|
18
|
+
const { ast, oneTime } = this.getAst(text);
|
|
19
|
+
const fn = this.astCompiler.compile(ast);
|
|
20
|
+
fn.literal = isLiteral(ast);
|
|
21
|
+
fn.constant = isConstant(ast);
|
|
22
|
+
fn.oneTime = oneTime;
|
|
23
|
+
return fn;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
getAst(exp) {
|
|
27
|
+
let oneTime = false;
|
|
28
|
+
exp = exp.trim();
|
|
29
|
+
|
|
30
|
+
if (exp.startsWith("::")) {
|
|
31
|
+
oneTime = true;
|
|
32
|
+
exp = exp.substring(2);
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
ast: this.ast.ast(exp),
|
|
36
|
+
oneTime,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { ASTType } from "./ast-type";
|
|
2
|
+
import { forEach, isFunction } from "../../shared/utils";
|
|
3
|
+
|
|
4
|
+
const objectValueOf = {}.constructor.prototype.valueOf;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Converts parameter to strings property name for use as keys in an object.
|
|
8
|
+
* Any non-string object, including a number, is typecasted into a string via the toString method.
|
|
9
|
+
* {@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Property_accessors#Property_names}
|
|
10
|
+
*
|
|
11
|
+
* @param {!any} name
|
|
12
|
+
* @returns {string}
|
|
13
|
+
*/
|
|
14
|
+
export function getStringValue(name) {
|
|
15
|
+
return `${name}`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/// //////////////////////////////////////
|
|
19
|
+
|
|
20
|
+
export function ifDefined(v, d) {
|
|
21
|
+
return typeof v !== "undefined" ? v : d;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function plusFn(l, r) {
|
|
25
|
+
if (typeof l === "undefined") return r;
|
|
26
|
+
if (typeof r === "undefined") return l;
|
|
27
|
+
return l + r;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function isStateless($filter, filterName) {
|
|
31
|
+
const fn = $filter(filterName);
|
|
32
|
+
return !fn.$stateful;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const PURITY_ABSOLUTE = 1;
|
|
36
|
+
export const PURITY_RELATIVE = 2;
|
|
37
|
+
|
|
38
|
+
// Detect nodes which could depend on non-shallow state of objects
|
|
39
|
+
export function isPure(node, parentIsPure) {
|
|
40
|
+
switch (node.type) {
|
|
41
|
+
// Computed members might invoke a stateful toString()
|
|
42
|
+
case ASTType.MemberExpression:
|
|
43
|
+
if (node.computed) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
break;
|
|
47
|
+
|
|
48
|
+
// Unary always convert to primative
|
|
49
|
+
case ASTType.UnaryExpression:
|
|
50
|
+
return PURITY_ABSOLUTE;
|
|
51
|
+
|
|
52
|
+
// The binary + operator can invoke a stateful toString().
|
|
53
|
+
case ASTType.BinaryExpression:
|
|
54
|
+
return node.operator !== "+" ? PURITY_ABSOLUTE : false;
|
|
55
|
+
|
|
56
|
+
// Functions / filters probably read state from within objects
|
|
57
|
+
case ASTType.CallExpression:
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return undefined === parentIsPure ? PURITY_RELATIVE : parentIsPure;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function findConstantAndWatchExpressions(ast, $filter, parentIsPure) {
|
|
65
|
+
let allConstants;
|
|
66
|
+
let argsToWatch;
|
|
67
|
+
let isStatelessFilter;
|
|
68
|
+
|
|
69
|
+
const astIsPure = (ast.isPure = isPure(ast, parentIsPure));
|
|
70
|
+
|
|
71
|
+
switch (ast.type) {
|
|
72
|
+
case ASTType.Program:
|
|
73
|
+
allConstants = true;
|
|
74
|
+
/** @type {[any]} */ (ast.body).forEach((expr) => {
|
|
75
|
+
findConstantAndWatchExpressions(expr.expression, $filter, astIsPure);
|
|
76
|
+
allConstants = allConstants && expr.expression.constant;
|
|
77
|
+
});
|
|
78
|
+
ast.constant = allConstants;
|
|
79
|
+
break;
|
|
80
|
+
case ASTType.Literal:
|
|
81
|
+
ast.constant = true;
|
|
82
|
+
ast.toWatch = [];
|
|
83
|
+
break;
|
|
84
|
+
case ASTType.UnaryExpression:
|
|
85
|
+
findConstantAndWatchExpressions(ast.argument, $filter, astIsPure);
|
|
86
|
+
ast.constant = ast.argument.constant;
|
|
87
|
+
ast.toWatch = ast.argument.toWatch;
|
|
88
|
+
break;
|
|
89
|
+
case ASTType.BinaryExpression:
|
|
90
|
+
findConstantAndWatchExpressions(ast.left, $filter, astIsPure);
|
|
91
|
+
findConstantAndWatchExpressions(ast.right, $filter, astIsPure);
|
|
92
|
+
ast.constant = ast.left.constant && ast.right.constant;
|
|
93
|
+
ast.toWatch = ast.left.toWatch.concat(ast.right.toWatch);
|
|
94
|
+
break;
|
|
95
|
+
case ASTType.LogicalExpression:
|
|
96
|
+
findConstantAndWatchExpressions(ast.left, $filter, astIsPure);
|
|
97
|
+
findConstantAndWatchExpressions(ast.right, $filter, astIsPure);
|
|
98
|
+
ast.constant = ast.left.constant && ast.right.constant;
|
|
99
|
+
ast.toWatch = ast.constant ? [] : [ast];
|
|
100
|
+
break;
|
|
101
|
+
case ASTType.ConditionalExpression:
|
|
102
|
+
findConstantAndWatchExpressions(ast.test, $filter, astIsPure);
|
|
103
|
+
findConstantAndWatchExpressions(ast.alternate, $filter, astIsPure);
|
|
104
|
+
findConstantAndWatchExpressions(ast.consequent, $filter, astIsPure);
|
|
105
|
+
ast.constant =
|
|
106
|
+
ast.test.constant && ast.alternate.constant && ast.consequent.constant;
|
|
107
|
+
ast.toWatch = ast.constant ? [] : [ast];
|
|
108
|
+
break;
|
|
109
|
+
case ASTType.Identifier:
|
|
110
|
+
ast.constant = false;
|
|
111
|
+
ast.toWatch = [ast];
|
|
112
|
+
break;
|
|
113
|
+
case ASTType.MemberExpression:
|
|
114
|
+
findConstantAndWatchExpressions(ast.object, $filter, astIsPure);
|
|
115
|
+
if (ast.computed) {
|
|
116
|
+
findConstantAndWatchExpressions(ast.property, $filter, astIsPure);
|
|
117
|
+
}
|
|
118
|
+
ast.constant =
|
|
119
|
+
ast.object.constant && (!ast.computed || ast.property.constant);
|
|
120
|
+
ast.toWatch = ast.constant ? [] : [ast];
|
|
121
|
+
break;
|
|
122
|
+
case ASTType.CallExpression:
|
|
123
|
+
isStatelessFilter = ast.filter
|
|
124
|
+
? isStateless($filter, ast.callee.name)
|
|
125
|
+
: false;
|
|
126
|
+
allConstants = isStatelessFilter;
|
|
127
|
+
argsToWatch = [];
|
|
128
|
+
forEach(ast.arguments, (expr) => {
|
|
129
|
+
findConstantAndWatchExpressions(expr, $filter, astIsPure);
|
|
130
|
+
allConstants = allConstants && expr.constant;
|
|
131
|
+
argsToWatch.push.apply(argsToWatch, expr.toWatch);
|
|
132
|
+
});
|
|
133
|
+
ast.constant = allConstants;
|
|
134
|
+
ast.toWatch = isStatelessFilter ? argsToWatch : [ast];
|
|
135
|
+
break;
|
|
136
|
+
case ASTType.AssignmentExpression:
|
|
137
|
+
findConstantAndWatchExpressions(ast.left, $filter, astIsPure);
|
|
138
|
+
findConstantAndWatchExpressions(ast.right, $filter, astIsPure);
|
|
139
|
+
ast.constant = ast.left.constant && ast.right.constant;
|
|
140
|
+
ast.toWatch = [ast];
|
|
141
|
+
break;
|
|
142
|
+
case ASTType.ArrayExpression:
|
|
143
|
+
allConstants = true;
|
|
144
|
+
argsToWatch = [];
|
|
145
|
+
forEach(ast.elements, (expr) => {
|
|
146
|
+
findConstantAndWatchExpressions(expr, $filter, astIsPure);
|
|
147
|
+
allConstants = allConstants && expr.constant;
|
|
148
|
+
argsToWatch.push.apply(argsToWatch, expr.toWatch);
|
|
149
|
+
});
|
|
150
|
+
ast.constant = allConstants;
|
|
151
|
+
ast.toWatch = argsToWatch;
|
|
152
|
+
break;
|
|
153
|
+
case ASTType.ObjectExpression:
|
|
154
|
+
allConstants = true;
|
|
155
|
+
argsToWatch = [];
|
|
156
|
+
forEach(ast.properties, (property) => {
|
|
157
|
+
findConstantAndWatchExpressions(property.value, $filter, astIsPure);
|
|
158
|
+
allConstants = allConstants && property.value.constant;
|
|
159
|
+
argsToWatch.push.apply(argsToWatch, property.value.toWatch);
|
|
160
|
+
if (property.computed) {
|
|
161
|
+
// `{[key]: value}` implicitly does `key.toString()` which may be non-pure
|
|
162
|
+
findConstantAndWatchExpressions(
|
|
163
|
+
property.key,
|
|
164
|
+
$filter,
|
|
165
|
+
/* parentIsPure= */ false,
|
|
166
|
+
);
|
|
167
|
+
allConstants = allConstants && property.key.constant;
|
|
168
|
+
argsToWatch.push.apply(argsToWatch, property.key.toWatch);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
ast.constant = allConstants;
|
|
172
|
+
ast.toWatch = argsToWatch;
|
|
173
|
+
break;
|
|
174
|
+
case ASTType.ThisExpression:
|
|
175
|
+
ast.constant = false;
|
|
176
|
+
ast.toWatch = [];
|
|
177
|
+
break;
|
|
178
|
+
case ASTType.LocalsExpression:
|
|
179
|
+
ast.constant = false;
|
|
180
|
+
ast.toWatch = [];
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export function getInputs(body) {
|
|
186
|
+
if (body.length !== 1) return;
|
|
187
|
+
const lastExpression = body[0].expression;
|
|
188
|
+
const candidate = lastExpression.toWatch;
|
|
189
|
+
if (candidate.length !== 1) return candidate;
|
|
190
|
+
return candidate[0] !== lastExpression ? candidate : undefined;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export function isAssignable(ast) {
|
|
194
|
+
return (
|
|
195
|
+
ast.type === ASTType.Identifier || ast.type === ASTType.MemberExpression
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export function assignableAST(ast) {
|
|
200
|
+
if (ast.body.length === 1 && isAssignable(ast.body[0].expression)) {
|
|
201
|
+
return {
|
|
202
|
+
type: ASTType.AssignmentExpression,
|
|
203
|
+
left: ast.body[0].expression,
|
|
204
|
+
right: { type: ASTType.NGValueParameter },
|
|
205
|
+
operator: "=",
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export function isLiteral(ast) {
|
|
211
|
+
return (
|
|
212
|
+
ast.body.length === 0 ||
|
|
213
|
+
(ast.body.length === 1 &&
|
|
214
|
+
(ast.body[0].expression.type === ASTType.Literal ||
|
|
215
|
+
ast.body[0].expression.type === ASTType.ArrayExpression ||
|
|
216
|
+
ast.body[0].expression.type === ASTType.ObjectExpression))
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export function isConstant(ast) {
|
|
221
|
+
return ast.constant;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export function getValueOf(value) {
|
|
225
|
+
return isFunction(value.valueOf)
|
|
226
|
+
? value.valueOf()
|
|
227
|
+
: objectValueOf.call(value);
|
|
228
|
+
}
|
package/src/core/q/q.spec.js
CHANGED
package/src/core/sce/sce.js
CHANGED
|
@@ -46,12 +46,9 @@ export const SCE_CONTEXTS = {
|
|
|
46
46
|
// http://docs.closure-library.googlecode.com/git/local_closure_goog_string_string.js.source.html#line1021
|
|
47
47
|
// Prereq: s is a string.
|
|
48
48
|
export function escapeForRegexp(s) {
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
// eslint-disable-next-line no-control-regex
|
|
53
|
-
.replace(/\x08/g, "\\x08")
|
|
54
|
-
);
|
|
49
|
+
return s
|
|
50
|
+
.replace(/([-()[\]{}+?*.$^|,:#<!\\])/g, "\\$1")
|
|
51
|
+
.replace(/\x08/g, "\\x08");
|
|
55
52
|
}
|
|
56
53
|
|
|
57
54
|
export function adjustMatcher(matcher) {
|
package/src/core/scope/scope.js
CHANGED
|
@@ -45,6 +45,10 @@ const $rootScopeMinErr = minErr("$rootScope");
|
|
|
45
45
|
/** @type {AsyncQueueTask[]} */
|
|
46
46
|
export const $$asyncQueue = [];
|
|
47
47
|
export const $$postDigestQueue = [];
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @type {Function[]}
|
|
51
|
+
*/
|
|
48
52
|
export const $$applyAsyncQueue = [];
|
|
49
53
|
let postDigestQueuePosition = 0;
|
|
50
54
|
let lastDirtyWatch = null;
|
|
@@ -84,9 +88,9 @@ export class $RootScopeProvider {
|
|
|
84
88
|
"$parse",
|
|
85
89
|
"$browser",
|
|
86
90
|
/**
|
|
91
|
+
* @param {import('../exception-handler').ErrorHandler} exceptionHandler
|
|
87
92
|
* @param {angular.IParseService} parse
|
|
88
|
-
* @param {import('
|
|
89
|
-
* @param {angular.IExceptionHandlerService} exceptionHandler
|
|
93
|
+
* @param {import('../../services/browser').Browser} browser
|
|
90
94
|
* @returns {Scope} root scope
|
|
91
95
|
*/
|
|
92
96
|
function (exceptionHandler, parse, browser) {
|
|
@@ -606,7 +610,6 @@ export class Scope {
|
|
|
606
610
|
oldItem = oldValue[i];
|
|
607
611
|
newItem = newValue[i];
|
|
608
612
|
|
|
609
|
-
// eslint-disable-next-line no-self-compare
|
|
610
613
|
bothNaN = oldItem !== oldItem && newItem !== newItem;
|
|
611
614
|
if (!bothNaN && oldItem !== newItem) {
|
|
612
615
|
changeDetected++;
|
|
@@ -629,7 +632,6 @@ export class Scope {
|
|
|
629
632
|
oldItem = oldValue[key];
|
|
630
633
|
|
|
631
634
|
if (key in oldValue) {
|
|
632
|
-
// eslint-disable-next-line no-self-compare
|
|
633
635
|
bothNaN = oldItem !== oldItem && newItem !== newItem;
|
|
634
636
|
if (!bothNaN && oldItem !== newItem) {
|
|
635
637
|
changeDetected++;
|
|
@@ -1238,13 +1240,19 @@ export class Scope {
|
|
|
1238
1240
|
} catch (e) {
|
|
1239
1241
|
$exceptionHandler(e);
|
|
1240
1242
|
} finally {
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1243
|
+
this.retry();
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
/**
|
|
1248
|
+
* @private
|
|
1249
|
+
*/
|
|
1250
|
+
retry() {
|
|
1251
|
+
try {
|
|
1252
|
+
this.$root.$digest();
|
|
1253
|
+
} catch (e) {
|
|
1254
|
+
$exceptionHandler(e);
|
|
1255
|
+
throw e;
|
|
1248
1256
|
}
|
|
1249
1257
|
}
|
|
1250
1258
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { forEach, isObject, isString } from "../../shared/utils";
|
|
2
2
|
|
|
3
3
|
function classDirective(name, selector) {
|
|
4
|
-
// eslint-disable-next-line no-param-reassign
|
|
5
4
|
name = `ngClass${name}`;
|
|
6
5
|
var indexWatchExpression;
|
|
7
6
|
|
|
@@ -24,7 +23,6 @@ function classDirective(name, selector) {
|
|
|
24
23
|
if (name !== "ngClass") {
|
|
25
24
|
if (!indexWatchExpression) {
|
|
26
25
|
indexWatchExpression = $parse("$index", function moduloTwo($index) {
|
|
27
|
-
// eslint-disable-next-line no-bitwise
|
|
28
26
|
return $index & 1;
|
|
29
27
|
});
|
|
30
28
|
}
|
|
@@ -244,7 +244,6 @@ FormController.prototype = {
|
|
|
244
244
|
forEach(
|
|
245
245
|
this.$pending,
|
|
246
246
|
function (value, name) {
|
|
247
|
-
// eslint-disable-next-line no-invalid-this
|
|
248
247
|
this.$setValidity(name, null, control);
|
|
249
248
|
},
|
|
250
249
|
this,
|
|
@@ -252,7 +251,6 @@ FormController.prototype = {
|
|
|
252
251
|
forEach(
|
|
253
252
|
this.$error,
|
|
254
253
|
function (value, name) {
|
|
255
|
-
// eslint-disable-next-line no-invalid-this
|
|
256
254
|
this.$setValidity(name, null, control);
|
|
257
255
|
},
|
|
258
256
|
this,
|
|
@@ -260,7 +258,6 @@ FormController.prototype = {
|
|
|
260
258
|
forEach(
|
|
261
259
|
this.$$success,
|
|
262
260
|
function (value, name) {
|
|
263
|
-
// eslint-disable-next-line no-invalid-this
|
|
264
261
|
this.$setValidity(name, null, control);
|
|
265
262
|
},
|
|
266
263
|
this,
|
|
@@ -34,7 +34,7 @@ export const ISO_DATE_REGEXP =
|
|
|
34
34
|
// 1111111111111111 222 333333 44444 55555555555555555555555 666 77777777 8888888 999
|
|
35
35
|
export const URL_REGEXP =
|
|
36
36
|
/^[a-z][a-z\d.+-]*:\/*(?:[^:@]+(?::[^@]+)?@)?(?:[^\s:/?#]+|\[[a-f\d:]+])(?::\d+)?(?:\/[^?#]*)?(?:\?[^#]*)?(?:#.*)?$/i;
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
export const EMAIL_REGEXP =
|
|
39
39
|
/^(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+(\.[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/;
|
|
40
40
|
const NUMBER_REGEXP = /^\s*(-|\+)?(\d+|(\d*(\.\d*)))([eE][+-]?\d+)?\s*$/;
|
|
@@ -1144,7 +1144,6 @@ export function isNumberInteger(num) {
|
|
|
1144
1144
|
// See http://stackoverflow.com/questions/14636536/how-to-check-if-a-variable-is-an-integer-in-javascript#14794066
|
|
1145
1145
|
// (minus the assumption that `num` is a number)
|
|
1146
1146
|
|
|
1147
|
-
// eslint-disable-next-line no-bitwise
|
|
1148
1147
|
return (num | 0) === num;
|
|
1149
1148
|
}
|
|
1150
1149
|
|
|
@@ -328,7 +328,6 @@ NgModelController.prototype = {
|
|
|
328
328
|
* @returns {boolean} True if `value` is "empty".
|
|
329
329
|
*/
|
|
330
330
|
$isEmpty(value) {
|
|
331
|
-
// eslint-disable-next-line no-self-compare
|
|
332
331
|
return (
|
|
333
332
|
isUndefined(value) || value === "" || value === null || value !== value
|
|
334
333
|
);
|
|
@@ -771,7 +770,6 @@ NgModelController.prototype = {
|
|
|
771
770
|
try {
|
|
772
771
|
listener();
|
|
773
772
|
} catch (e) {
|
|
774
|
-
// eslint-disable-next-line no-invalid-this
|
|
775
773
|
this.$$exceptionHandler(e);
|
|
776
774
|
}
|
|
777
775
|
},
|
|
@@ -1082,7 +1080,7 @@ function setupModelWatcher(ctrl) {
|
|
|
1082
1080
|
if (
|
|
1083
1081
|
modelValue !== ctrl.$modelValue &&
|
|
1084
1082
|
// checks for NaN is needed to allow setting the model to NaN when there's an asyncValidator
|
|
1085
|
-
|
|
1083
|
+
|
|
1086
1084
|
(ctrl.$modelValue === ctrl.$modelValue || modelValue === modelValue)
|
|
1087
1085
|
) {
|
|
1088
1086
|
ctrl.$$setModelValue(modelValue);
|
|
@@ -1173,7 +1173,6 @@ describe("ngModel", () => {
|
|
|
1173
1173
|
});
|
|
1174
1174
|
|
|
1175
1175
|
it("should be possible to extend Object prototype and still be able to do form validation", () => {
|
|
1176
|
-
// eslint-disable-next-line no-extend-native
|
|
1177
1176
|
Object.prototype.someThing = function () {};
|
|
1178
1177
|
const element = $compile(
|
|
1179
1178
|
'<form name="myForm">' +
|
|
@@ -129,7 +129,6 @@ describe("ngRepeat", () => {
|
|
|
129
129
|
|
|
130
130
|
it("should iterate over an array-like class", () => {
|
|
131
131
|
function Collection() {}
|
|
132
|
-
// eslint-disable-next-line no-array-constructor
|
|
133
132
|
Collection.prototype = new Array();
|
|
134
133
|
Collection.prototype.length = 0;
|
|
135
134
|
|
|
@@ -296,7 +295,6 @@ describe("ngRepeat", () => {
|
|
|
296
295
|
"</ul>",
|
|
297
296
|
)(scope);
|
|
298
297
|
|
|
299
|
-
// eslint-disable-next-line no-extend-native
|
|
300
298
|
Array.prototype.extraProperty = "should be ignored";
|
|
301
299
|
// INIT
|
|
302
300
|
scope.items = [true, true, true];
|
package/src/exts/aria/aria.js
CHANGED
package/src/injector.js
CHANGED
|
@@ -275,7 +275,7 @@ export function createInjector(modulesToLoad, strictDi) {
|
|
|
275
275
|
// unlike those of Chrome and IE
|
|
276
276
|
// So if stack doesn't contain message, we create a new string that contains both.
|
|
277
277
|
// Since error.stack is read-only in Safari, I'm overriding e and not e.stack here.
|
|
278
|
-
|
|
278
|
+
|
|
279
279
|
e = `${e.message}\n${e.stack}`;
|
|
280
280
|
}
|
|
281
281
|
throw $injectorMinErr(
|
package/src/injector.spec.js
CHANGED
|
@@ -461,21 +461,17 @@ describe("annotate", () => {
|
|
|
461
461
|
|
|
462
462
|
describe("es6", () => {
|
|
463
463
|
it("should be possible to annotate shorthand methods", () => {
|
|
464
|
-
// eslint-disable-next-line no-eval
|
|
465
464
|
expect(annotate(eval("({ fn(x) { return; } })").fn)).toEqual(["x"]);
|
|
466
465
|
});
|
|
467
466
|
|
|
468
467
|
it("should create $inject for arrow functions", () => {
|
|
469
|
-
// eslint-disable-next-line no-eval
|
|
470
468
|
expect(annotate(eval("(a, b) => a"))).toEqual(["a", "b"]);
|
|
471
469
|
});
|
|
472
470
|
it("should create $inject for arrow functions with no parenthesis", () => {
|
|
473
|
-
// eslint-disable-next-line no-eval
|
|
474
471
|
expect(annotate(eval("a => a"))).toEqual(["a"]);
|
|
475
472
|
});
|
|
476
473
|
|
|
477
474
|
it("should take args before first arrow", () => {
|
|
478
|
-
// eslint-disable-next-line no-eval
|
|
479
475
|
expect(annotate(eval("a => b => b"))).toEqual(["a"]);
|
|
480
476
|
});
|
|
481
477
|
|
|
@@ -492,7 +488,6 @@ describe("annotate", () => {
|
|
|
492
488
|
"class/* Test */{}",
|
|
493
489
|
"class /* Test */ {}",
|
|
494
490
|
].forEach((classDefinition) => {
|
|
495
|
-
// eslint-disable-next-line no-eval
|
|
496
491
|
const Clazz = eval(`(${classDefinition})`);
|
|
497
492
|
const instance = injector.invoke(Clazz);
|
|
498
493
|
|
package/src/loader.js
CHANGED
|
@@ -174,7 +174,6 @@ export class Angular {
|
|
|
174
174
|
* @returns {angular.auto.IInjectorService} Returns the newly created injector for this app.
|
|
175
175
|
*/
|
|
176
176
|
bootstrap(element, modules, config) {
|
|
177
|
-
// eslint-disable-next-line no-param-reassign
|
|
178
177
|
config = config || {
|
|
179
178
|
debugInfoEnabled: false,
|
|
180
179
|
strictDi: false,
|
|
@@ -333,7 +332,6 @@ export class Angular {
|
|
|
333
332
|
}
|
|
334
333
|
|
|
335
334
|
function ensure(obj, name, factory) {
|
|
336
|
-
// eslint-disable-next-line no-return-assign, no-param-reassign
|
|
337
335
|
return obj[name] || (obj[name] = factory());
|
|
338
336
|
}
|
|
339
337
|
|
|
@@ -357,7 +355,6 @@ export class Angular {
|
|
|
357
355
|
/** @type {!Array.<Function>} */
|
|
358
356
|
const runBlocks = [];
|
|
359
357
|
|
|
360
|
-
// eslint-disable-next-line no-use-before-define
|
|
361
358
|
const config = invokeLater("$injector", "invoke", "push", configBlocks);
|
|
362
359
|
|
|
363
360
|
/** @type {import('./types').Module} */
|
|
@@ -883,7 +880,6 @@ export function setupModuleLoader(window) {
|
|
|
883
880
|
const $injectorMinErr = minErr("$injector");
|
|
884
881
|
|
|
885
882
|
function ensure(obj, name, factory) {
|
|
886
|
-
// eslint-disable-next-line no-return-assign
|
|
887
883
|
return obj[name] || (obj[name] = factory());
|
|
888
884
|
}
|
|
889
885
|
|
|
@@ -974,7 +970,6 @@ export function setupModuleLoader(window) {
|
|
|
974
970
|
/** @type {!Array.<Function>} */
|
|
975
971
|
const runBlocks = [];
|
|
976
972
|
|
|
977
|
-
// eslint-disable-next-line no-use-before-define
|
|
978
973
|
const config = invokeLater("$injector", "invoke", "push", configBlocks);
|
|
979
974
|
|
|
980
975
|
/** @type {import('./types').Module} */
|
|
@@ -43,7 +43,6 @@ export function $$CookieReader($document) {
|
|
|
43
43
|
cookieArray = lastCookieString.split("; ");
|
|
44
44
|
lastCookies = {};
|
|
45
45
|
|
|
46
|
-
// eslint-disable-next-line no-plusplus
|
|
47
46
|
for (i = 0; i < cookieArray.length; i++) {
|
|
48
47
|
cookie = cookieArray[i];
|
|
49
48
|
index = cookie.indexOf("=");
|
|
@@ -2417,7 +2417,6 @@ describe("$http", function () {
|
|
|
2417
2417
|
// it("should ignore Blob objects", () => {
|
|
2418
2418
|
// if (!window.Blob) return;
|
|
2419
2419
|
|
|
2420
|
-
// // eslint-disable-next-line no-undef
|
|
2421
2420
|
// const blob = new Blob(["blob!"], { type: "text/plain" });
|
|
2422
2421
|
|
|
2423
2422
|
// $httpBackend.expect("POST", "/url", "[object Blob]").respond("");
|
|
@@ -2427,7 +2426,6 @@ describe("$http", function () {
|
|
|
2427
2426
|
// it("should ignore FormData objects", () => {
|
|
2428
2427
|
// if (!window.FormData) return;
|
|
2429
2428
|
|
|
2430
|
-
// // eslint-disable-next-line no-undef
|
|
2431
2429
|
// const formData = new FormData();
|
|
2432
2430
|
// formData.append("angular", "is great");
|
|
2433
2431
|
|