@angular-wave/angular.ts 0.0.66 → 0.0.68
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/animations/animate-js.js +4 -4
- package/src/animations/animate-swap.js +3 -0
- package/src/core/compile/compile.js +3 -3
- package/src/core/controller/controller.js +0 -5
- package/src/core/di/injector.js +9 -12
- package/src/core/di/internal-injector.js +113 -60
- package/src/core/interval/interval-factory.js +8 -1
- package/src/core/interval/interval.js +30 -16
- package/src/core/location/location.js +473 -626
- package/src/core/location/location.md +114 -0
- package/src/core/location/location.spec.js +1 -76
- package/src/core/parser/parse.js +1 -12
- package/src/core/parser/parse.spec.js +96 -110
- package/src/core/q/q.js +63 -65
- package/src/core/sce/sce.js +1 -3
- package/src/core/scope/scope.js +2 -5
- package/src/core/timeout/timeout.js +110 -111
- package/src/core/url-utils/url-utils.js +5 -0
- package/src/directive/input/input.js +32 -726
- package/src/directive/input/input.md +706 -0
- package/src/directive/options/options.js +2 -156
- package/src/directive/options/options.md +179 -0
- package/src/directive/select/select.js +55 -126
- package/src/directive/select/select.md +74 -0
- package/src/directive/show-hide/show-hide.js +13 -224
- package/src/directive/show-hide/show-hide.md +257 -0
- package/src/exts/messages/messages.js +2 -0
- package/src/filters/limit-to.spec.js +1 -1
- package/src/filters/order-by.spec.js +1 -1
- package/src/index.js +6 -2
- package/src/loader.js +7 -3
- package/src/public.js +1 -7
- package/src/router/params/param.js +54 -54
- package/src/router/path/path-utils.js +1 -0
- package/src/router/state/state-builder.js +2 -4
- package/src/router/state/state-service.js +1 -1
- package/src/router/state-provider.js +1 -1
- package/src/router/template-factory.js +10 -10
- package/src/router/url/url-service.js +11 -4
- package/src/services/anchor-scroll.js +3 -5
- package/src/services/browser.js +2 -9
- package/src/services/cache-factory.js +0 -67
- package/src/services/cache-factory.md +75 -0
- package/src/services/cookie-reader.js +36 -55
- package/src/services/http/http.js +62 -587
- package/src/services/http/http.md +413 -0
- package/src/services/http-backend/http-backend.js +19 -44
- package/src/services/template-request.js +1 -9
- package/src/shared/jqlite/jqlite.js +5 -70
- package/src/types.js +2 -4
- package/types/animations/animate-swap.d.ts +4 -7
- package/types/core/compile/compile.d.ts +6 -6
- package/types/core/controller/controller.d.ts +0 -5
- package/types/core/di/internal-injector.d.ts +73 -18
- package/types/core/exception-handler.d.ts +1 -1
- package/types/core/interval/interval-factory.d.ts +1 -1
- package/types/core/interval/interval.d.ts +4 -0
- package/types/core/location/location.d.ts +235 -166
- package/types/core/parser/parse.d.ts +1 -1
- package/types/core/q/q.d.ts +61 -40
- package/types/core/scope/scope.d.ts +5 -8
- package/types/core/timeout/timeout.d.ts +16 -26
- package/types/core/url-utils/url-utils.d.ts +4 -0
- package/types/directive/input/input.d.ts +19 -124
- package/types/directive/select/select.d.ts +7 -74
- package/types/directive/show-hide/show-hide.d.ts +11 -224
- package/types/loader.d.ts +4 -4
- package/types/router/params/param.d.ts +11 -0
- package/types/router/state/state-builder.d.ts +1 -2
- package/types/router/state/state-service.d.ts +2 -2
- package/types/router/state-provider.d.ts +2 -2
- package/types/router/template-factory.d.ts +15 -15
- package/types/router/url/url-service.d.ts +12 -12
- package/types/services/anchor-scroll.d.ts +1 -1
- package/types/services/browser.d.ts +0 -10
- package/types/services/cache-factory.d.ts +0 -67
- package/types/services/cookie-reader.d.ts +2 -10
- package/types/services/http/http.d.ts +53 -61
- package/types/services/http-backend/http-backend.d.ts +8 -31
- package/types/services/template-request.d.ts +1 -9
- package/types/shared/jqlite/jqlite.d.ts +11 -11
- package/types/types.d.ts +1 -9
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/\*\*
|
|
2
|
+
|
|
3
|
+
- The $location service parses the URL in the browser address bar (based on the
|
|
4
|
+
- [window.location](https://developer.mozilla.org/en/window.location)) and makes the URL
|
|
5
|
+
- available to your application. Changes to the URL in the address bar are reflected into
|
|
6
|
+
- $location service and changes to $location are reflected into the browser address bar.
|
|
7
|
+
-
|
|
8
|
+
- **The $location service:**
|
|
9
|
+
-
|
|
10
|
+
- - Exposes the current URL in the browser address bar, so you can
|
|
11
|
+
- - Watch and observe the URL.
|
|
12
|
+
- - Change the URL.
|
|
13
|
+
- - Synchronizes the URL with the browser when the user
|
|
14
|
+
- - Changes the address bar.
|
|
15
|
+
- - Clicks the back or forward button (or clicks a History link).
|
|
16
|
+
- - Clicks on a link.
|
|
17
|
+
- - Represents the URL object as a set of methods (protocol, host, port, path, search, hash).
|
|
18
|
+
-
|
|
19
|
+
- For more information see {@link guide/$location Developer Guide: Using $location}
|
|
20
|
+
\*/
|
|
21
|
+
|
|
22
|
+
/\*\*
|
|
23
|
+
|
|
24
|
+
- Use the `$locationProvider` to configure how the application deep linking paths are stored.
|
|
25
|
+
\*/
|
|
26
|
+
|
|
27
|
+
/\*\*
|
|
28
|
+
|
|
29
|
+
- @ngdoc event
|
|
30
|
+
- @name $location#$locationChangeStart
|
|
31
|
+
- @eventType broadcast on root scope
|
|
32
|
+
- @description
|
|
33
|
+
- Broadcasted before a URL will change.
|
|
34
|
+
-
|
|
35
|
+
- This change can be prevented by calling
|
|
36
|
+
- `preventDefault` method of the event. See {@link ng.$rootScope.Scope#$on} for more
|
|
37
|
+
- details about event object. Upon successful change
|
|
38
|
+
- {@link ng.$location#$locationChangeSuccess $locationChangeSuccess} is fired.
|
|
39
|
+
-
|
|
40
|
+
- The `newState` and `oldState` parameters may be defined only in HTML5 mode and when
|
|
41
|
+
- the browser supports the HTML5 History API.
|
|
42
|
+
-
|
|
43
|
+
- @param {Object} angularEvent Synthetic event object.
|
|
44
|
+
- @param {string} newUrl New URL
|
|
45
|
+
- @param {string=} oldUrl URL that was before it was changed.
|
|
46
|
+
- @param {string=} newState New history state object
|
|
47
|
+
- @param {string=} oldState History state object that was before it was changed.
|
|
48
|
+
\*/
|
|
49
|
+
|
|
50
|
+
/\*\*
|
|
51
|
+
|
|
52
|
+
- @ngdoc event
|
|
53
|
+
- @name $location#$locationChangeSuccess
|
|
54
|
+
- @eventType broadcast on root scope
|
|
55
|
+
- @description
|
|
56
|
+
- Broadcasted after a URL was changed.
|
|
57
|
+
-
|
|
58
|
+
- The `newState` and `oldState` parameters may be defined only in HTML5 mode and when
|
|
59
|
+
- the browser supports the HTML5 History API.
|
|
60
|
+
-
|
|
61
|
+
- @param {Object} angularEvent Synthetic event object.
|
|
62
|
+
- @param {string} newUrl New URL
|
|
63
|
+
- @param {string=} oldUrl URL that was before it was changed.
|
|
64
|
+
- @param {string=} newState New history state object
|
|
65
|
+
- @param {string=} oldState History state object that was before it was changed.
|
|
66
|
+
\*/
|
|
67
|
+
|
|
68
|
+
/\*\*
|
|
69
|
+
|
|
70
|
+
- This method is getter / setter.
|
|
71
|
+
-
|
|
72
|
+
- Return search part (as object) of current URL when called without any parameter.
|
|
73
|
+
-
|
|
74
|
+
- Change search part when called with parameter and return `$location`.
|
|
75
|
+
-
|
|
76
|
+
-
|
|
77
|
+
- ```js
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
- // given URL http://example.com/#/some/path?foo=bar&baz=xoxo
|
|
82
|
+
- let searchObject = $location.search();
|
|
83
|
+
- // => {foo: 'bar', baz: 'xoxo'}
|
|
84
|
+
-
|
|
85
|
+
- // set foo to 'yipee'
|
|
86
|
+
- $location.search('foo', 'yipee');
|
|
87
|
+
- // $location.search() => {foo: 'yipee', baz: 'xoxo'}
|
|
88
|
+
- ```
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
-
|
|
93
|
+
- @param {string|Object} search New search params - string or hash object.
|
|
94
|
+
-
|
|
95
|
+
- When called with a single argument the method acts as a setter, setting the `search` component
|
|
96
|
+
- of `$location` to the specified value.
|
|
97
|
+
-
|
|
98
|
+
- If the argument is a hash object containing an array of values, these values will be encoded
|
|
99
|
+
- as duplicate search parameters in the URL.
|
|
100
|
+
-
|
|
101
|
+
- @param {(string|Number|Array<string>|boolean)=} paramValue If `search` is a string or number, then `paramValue`
|
|
102
|
+
- will override only a single search property.
|
|
103
|
+
-
|
|
104
|
+
- If `paramValue` is an array, it will override the property of the `search` component of
|
|
105
|
+
- `$location` specified via the first argument.
|
|
106
|
+
-
|
|
107
|
+
- If `paramValue` is `null`, the property specified via the first argument will be deleted.
|
|
108
|
+
-
|
|
109
|
+
- If `paramValue` is `true`, the property specified via the first argument will be added with no
|
|
110
|
+
- value nor trailing equal sign.
|
|
111
|
+
-
|
|
112
|
+
- @return {Object} If called with no arguments returns the parsed `search` object. If called with
|
|
113
|
+
- one or more arguments returns `$location` object itself.
|
|
114
|
+
\*/
|
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
LocationHtml5Url,
|
|
3
3
|
LocationHashbangUrl,
|
|
4
4
|
$LocationProvider,
|
|
5
|
-
LocationHashbangInHtml5Url,
|
|
6
5
|
} from "./location";
|
|
7
6
|
import { Angular } from "../../loader";
|
|
8
7
|
import { createInjector } from "../../core/di/injector";
|
|
@@ -464,6 +463,7 @@ describe("$location", () => {
|
|
|
464
463
|
.hash("abcd")
|
|
465
464
|
.state({ a: 2 })
|
|
466
465
|
.search("bar", "baz");
|
|
466
|
+
|
|
467
467
|
expect(locationUrl.path()).toEqual("/foo");
|
|
468
468
|
expect(locationUrl.state()).toEqual({ a: 2 });
|
|
469
469
|
expect(locationUrl.search() && locationUrl.search().bar).toBe("baz");
|
|
@@ -3310,81 +3310,6 @@ describe("$location", () => {
|
|
|
3310
3310
|
});
|
|
3311
3311
|
});
|
|
3312
3312
|
|
|
3313
|
-
describe("LocationHashbangInHtml5Url", () => {
|
|
3314
|
-
/* global LocationHashbangInHtml5Url: false */
|
|
3315
|
-
let locationUrl;
|
|
3316
|
-
let locationIndexUrl;
|
|
3317
|
-
|
|
3318
|
-
beforeEach(() => {
|
|
3319
|
-
locationUrl = new LocationHashbangInHtml5Url(
|
|
3320
|
-
"http://server/pre/",
|
|
3321
|
-
"http://server/pre/",
|
|
3322
|
-
"#!",
|
|
3323
|
-
);
|
|
3324
|
-
locationIndexUrl = new LocationHashbangInHtml5Url(
|
|
3325
|
-
"http://server/pre/index.html",
|
|
3326
|
-
"http://server/pre/",
|
|
3327
|
-
"#!",
|
|
3328
|
-
);
|
|
3329
|
-
});
|
|
3330
|
-
|
|
3331
|
-
it("should rewrite URL", () => {
|
|
3332
|
-
expect(parseLinkAndReturn(locationUrl, "http://other")).toEqual(
|
|
3333
|
-
undefined,
|
|
3334
|
-
);
|
|
3335
|
-
expect(parseLinkAndReturn(locationUrl, "http://server/pre")).toEqual(
|
|
3336
|
-
"http://server/pre/#!",
|
|
3337
|
-
);
|
|
3338
|
-
expect(parseLinkAndReturn(locationUrl, "http://server/pre/")).toEqual(
|
|
3339
|
-
"http://server/pre/#!",
|
|
3340
|
-
);
|
|
3341
|
-
expect(
|
|
3342
|
-
parseLinkAndReturn(locationUrl, "http://server/pre/otherPath"),
|
|
3343
|
-
).toEqual("http://server/pre/#!/otherPath");
|
|
3344
|
-
// Note: relies on the previous state!
|
|
3345
|
-
expect(
|
|
3346
|
-
parseLinkAndReturn(locationUrl, "someIgnoredAbsoluteHref", "#test"),
|
|
3347
|
-
).toEqual("http://server/pre/#!/otherPath#test");
|
|
3348
|
-
|
|
3349
|
-
expect(parseLinkAndReturn(locationIndexUrl, "http://server/pre")).toEqual(
|
|
3350
|
-
"http://server/pre/index.html#!",
|
|
3351
|
-
);
|
|
3352
|
-
expect(
|
|
3353
|
-
parseLinkAndReturn(locationIndexUrl, "http://server/pre/"),
|
|
3354
|
-
).toEqual(undefined);
|
|
3355
|
-
expect(
|
|
3356
|
-
parseLinkAndReturn(locationIndexUrl, "http://server/pre/otherPath"),
|
|
3357
|
-
).toEqual("http://server/pre/index.html#!/otherPath");
|
|
3358
|
-
// Note: relies on the previous state!
|
|
3359
|
-
expect(
|
|
3360
|
-
parseLinkAndReturn(
|
|
3361
|
-
locationIndexUrl,
|
|
3362
|
-
"someIgnoredAbsoluteHref",
|
|
3363
|
-
"#test",
|
|
3364
|
-
),
|
|
3365
|
-
).toEqual("http://server/pre/index.html#!/otherPath#test");
|
|
3366
|
-
});
|
|
3367
|
-
|
|
3368
|
-
it("should throw on url(urlString, stateObject)", () => {
|
|
3369
|
-
expectThrowOnStateChange(locationUrl);
|
|
3370
|
-
});
|
|
3371
|
-
|
|
3372
|
-
// it("should not throw when base path is another domain", () => {
|
|
3373
|
-
// initService({ html5Mode: true, hashPrefix: "!", supportHistory: true });
|
|
3374
|
-
// inject(
|
|
3375
|
-
// initBrowser({
|
|
3376
|
-
// url: "http://domain.com/base/",
|
|
3377
|
-
// basePath: "http://otherdomain.com/base/",
|
|
3378
|
-
// }),
|
|
3379
|
-
// ($location) => {
|
|
3380
|
-
// expect(() => {
|
|
3381
|
-
// $location.absUrl();
|
|
3382
|
-
// }).not.toThrow();
|
|
3383
|
-
// },
|
|
3384
|
-
// );
|
|
3385
|
-
// });
|
|
3386
|
-
});
|
|
3387
|
-
|
|
3388
3313
|
// function mockUpBrowser(options) {
|
|
3389
3314
|
// module(($windowProvider, $browserProvider) => {
|
|
3390
3315
|
// let browser;
|
package/src/core/parser/parse.js
CHANGED
|
@@ -15,7 +15,7 @@ import { Parser } from "./parser";
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* @typedef {
|
|
18
|
+
* @typedef {Function} CompiledExpressionFunction
|
|
19
19
|
* @param {import('../scope/scope').Scope} context - An object against which any expressions embedded in the strings are evaluated against (typically a scope object).
|
|
20
20
|
* @param {object} [locals] - local variables context object, useful for overriding values in `context`.
|
|
21
21
|
* @param {any} [assign]
|
|
@@ -81,7 +81,6 @@ export function $ParseProvider() {
|
|
|
81
81
|
isIdentifierStart: isFunction(identStart) && identStart,
|
|
82
82
|
isIdentifierContinue: isFunction(identContinue) && identContinue,
|
|
83
83
|
};
|
|
84
|
-
$parse.$$getAst = $$getAst;
|
|
85
84
|
return $parse;
|
|
86
85
|
|
|
87
86
|
function $parse(exp, interceptorFn) {
|
|
@@ -111,16 +110,6 @@ export function $ParseProvider() {
|
|
|
111
110
|
}
|
|
112
111
|
}
|
|
113
112
|
|
|
114
|
-
/**
|
|
115
|
-
* @param {string} exp
|
|
116
|
-
* @returns {import("./ast").ASTNode}
|
|
117
|
-
*/
|
|
118
|
-
function $$getAst(exp) {
|
|
119
|
-
var lexer = new Lexer($lexerOptions);
|
|
120
|
-
var parser = new Parser(lexer, $filter);
|
|
121
|
-
return parser.getAst(exp).ast;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
113
|
function addInterceptor(parsedExpression, interceptorFn) {
|
|
125
114
|
if (!interceptorFn) return parsedExpression;
|
|
126
115
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AST } from "./ast";
|
|
2
2
|
import { Lexer } from "./lexer";
|
|
3
3
|
import {
|
|
4
|
-
forEach,
|
|
5
4
|
isFunction,
|
|
6
5
|
sliceArgs,
|
|
7
6
|
csp,
|
|
@@ -580,27 +579,24 @@ describe("parser", () => {
|
|
|
580
579
|
|
|
581
580
|
it("should understand literals", () => {
|
|
582
581
|
// In a strict sense, `undefined` is not a literal but an identifier
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
{
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
});
|
|
602
|
-
},
|
|
603
|
-
);
|
|
582
|
+
Object.entries({
|
|
583
|
+
123: 123,
|
|
584
|
+
'"123"': "123",
|
|
585
|
+
true: true,
|
|
586
|
+
false: false,
|
|
587
|
+
null: null,
|
|
588
|
+
undefined: undefined,
|
|
589
|
+
}).forEach(([expression, value]) => {
|
|
590
|
+
expect(createAst(expression)).toEqual({
|
|
591
|
+
type: ASTType.Program,
|
|
592
|
+
body: [
|
|
593
|
+
{
|
|
594
|
+
type: ASTType.ExpressionStatement,
|
|
595
|
+
expression: { type: ASTType.Literal, value },
|
|
596
|
+
},
|
|
597
|
+
],
|
|
598
|
+
});
|
|
599
|
+
});
|
|
604
600
|
});
|
|
605
601
|
|
|
606
602
|
it("should understand the `this` expression", () => {
|
|
@@ -628,8 +624,7 @@ describe("parser", () => {
|
|
|
628
624
|
});
|
|
629
625
|
|
|
630
626
|
it("should not confuse `this`, `$locals`, `undefined`, `true`, `false`, `null` when used as identifiers", () => {
|
|
631
|
-
forEach(
|
|
632
|
-
["this", "$locals", "undefined", "true", "false", "null"],
|
|
627
|
+
["this", "$locals", "undefined", "true", "false", "null"].forEach(
|
|
633
628
|
(identifier) => {
|
|
634
629
|
expect(createAst(`foo.${identifier}`)).toEqual({
|
|
635
630
|
type: ASTType.Program,
|
|
@@ -662,7 +657,7 @@ describe("parser", () => {
|
|
|
662
657
|
});
|
|
663
658
|
|
|
664
659
|
it("should understand the unary operators `-`, `+` and `!`", () => {
|
|
665
|
-
|
|
660
|
+
["-", "+", "!"].forEach((operator) => {
|
|
666
661
|
expect(createAst(`${operator}foo`)).toEqual({
|
|
667
662
|
type: ASTType.Program,
|
|
668
663
|
body: [
|
|
@@ -681,75 +676,69 @@ describe("parser", () => {
|
|
|
681
676
|
});
|
|
682
677
|
|
|
683
678
|
it("should handle all unary operators with the same precedence", () => {
|
|
684
|
-
|
|
685
|
-
[
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
{
|
|
695
|
-
type: ASTType.
|
|
696
|
-
|
|
679
|
+
[
|
|
680
|
+
["+", "-", "!"],
|
|
681
|
+
["-", "!", "+"],
|
|
682
|
+
["!", "+", "-"],
|
|
683
|
+
].forEach((operators) => {
|
|
684
|
+
expect(createAst(`${operators.join("")}foo`)).toEqual({
|
|
685
|
+
type: ASTType.Program,
|
|
686
|
+
body: [
|
|
687
|
+
{
|
|
688
|
+
type: ASTType.ExpressionStatement,
|
|
689
|
+
expression: {
|
|
690
|
+
type: ASTType.UnaryExpression,
|
|
691
|
+
operator: operators[0],
|
|
692
|
+
prefix: true,
|
|
693
|
+
argument: {
|
|
697
694
|
type: ASTType.UnaryExpression,
|
|
698
|
-
operator: operators[
|
|
695
|
+
operator: operators[1],
|
|
699
696
|
prefix: true,
|
|
700
697
|
argument: {
|
|
701
698
|
type: ASTType.UnaryExpression,
|
|
702
|
-
operator: operators[
|
|
699
|
+
operator: operators[2],
|
|
703
700
|
prefix: true,
|
|
704
|
-
argument: {
|
|
705
|
-
type: ASTType.UnaryExpression,
|
|
706
|
-
operator: operators[2],
|
|
707
|
-
prefix: true,
|
|
708
|
-
argument: { type: ASTType.Identifier, name: "foo" },
|
|
709
|
-
},
|
|
701
|
+
argument: { type: ASTType.Identifier, name: "foo" },
|
|
710
702
|
},
|
|
711
703
|
},
|
|
712
704
|
},
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
}
|
|
716
|
-
);
|
|
705
|
+
},
|
|
706
|
+
],
|
|
707
|
+
});
|
|
708
|
+
});
|
|
717
709
|
});
|
|
718
710
|
|
|
719
711
|
it("should be able to understand binary operators", () => {
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
{
|
|
741
|
-
type: ASTType.
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
left: { type: ASTType.Identifier, name: "foo" },
|
|
746
|
-
right: { type: ASTType.Identifier, name: "bar" },
|
|
747
|
-
},
|
|
712
|
+
[
|
|
713
|
+
"*",
|
|
714
|
+
"/",
|
|
715
|
+
"%",
|
|
716
|
+
"+",
|
|
717
|
+
"-",
|
|
718
|
+
"<",
|
|
719
|
+
">",
|
|
720
|
+
"<=",
|
|
721
|
+
">=",
|
|
722
|
+
"==",
|
|
723
|
+
"!=",
|
|
724
|
+
"===",
|
|
725
|
+
"!==",
|
|
726
|
+
].forEach((operator) => {
|
|
727
|
+
expect(createAst(`foo${operator}bar`)).toEqual({
|
|
728
|
+
type: ASTType.Program,
|
|
729
|
+
body: [
|
|
730
|
+
{
|
|
731
|
+
type: ASTType.ExpressionStatement,
|
|
732
|
+
expression: {
|
|
733
|
+
type: ASTType.BinaryExpression,
|
|
734
|
+
operator,
|
|
735
|
+
left: { type: ASTType.Identifier, name: "foo" },
|
|
736
|
+
right: { type: ASTType.Identifier, name: "bar" },
|
|
748
737
|
},
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
}
|
|
752
|
-
);
|
|
738
|
+
},
|
|
739
|
+
],
|
|
740
|
+
});
|
|
741
|
+
});
|
|
753
742
|
});
|
|
754
743
|
|
|
755
744
|
it("should associate binary operators with the same precedence left-to-right", () => {
|
|
@@ -759,9 +748,9 @@ describe("parser", () => {
|
|
|
759
748
|
["<", ">", "<=", ">="],
|
|
760
749
|
["==", "!=", "===", "!=="],
|
|
761
750
|
];
|
|
762
|
-
forEach(
|
|
763
|
-
forEach(
|
|
764
|
-
forEach(
|
|
751
|
+
operatorsByPrecedence.forEach((operators) => {
|
|
752
|
+
operators.forEach((op1) => {
|
|
753
|
+
operators.forEach((op2) => {
|
|
765
754
|
expect(createAst(`foo${op1}bar${op2}baz`)).toEqual({
|
|
766
755
|
type: ASTType.Program,
|
|
767
756
|
body: [
|
|
@@ -787,7 +776,7 @@ describe("parser", () => {
|
|
|
787
776
|
});
|
|
788
777
|
|
|
789
778
|
it("should give higher precedence to member calls than to unary expressions", () => {
|
|
790
|
-
|
|
779
|
+
["!", "+", "-"].forEach((operator) => {
|
|
791
780
|
expect(createAst(`${operator}foo()`)).toEqual({
|
|
792
781
|
type: ASTType.Program,
|
|
793
782
|
body: [
|
|
@@ -848,8 +837,8 @@ describe("parser", () => {
|
|
|
848
837
|
});
|
|
849
838
|
|
|
850
839
|
it("should give higher precedence to unary operators over multiplicative operators", () => {
|
|
851
|
-
|
|
852
|
-
|
|
840
|
+
["!", "+", "-"].forEach((op1) => {
|
|
841
|
+
["*", "/", "%"].forEach((op2) => {
|
|
853
842
|
expect(createAst(`${op1}foo${op2}${op1}bar`)).toEqual({
|
|
854
843
|
type: ASTType.Program,
|
|
855
844
|
body: [
|
|
@@ -886,8 +875,8 @@ describe("parser", () => {
|
|
|
886
875
|
["==", "!=", "===", "!=="],
|
|
887
876
|
];
|
|
888
877
|
for (let i = 0; i < operatorsByPrecedence.length - 1; ++i) {
|
|
889
|
-
|
|
890
|
-
|
|
878
|
+
operatorsByPrecedence[i].forEach((op1) => {
|
|
879
|
+
operatorsByPrecedence[i + 1].forEach((op2) => {
|
|
891
880
|
expect(createAst(`foo${op1}bar${op2}baz${op1}man`)).toEqual({
|
|
892
881
|
type: ASTType.Program,
|
|
893
882
|
body: [
|
|
@@ -918,7 +907,7 @@ describe("parser", () => {
|
|
|
918
907
|
});
|
|
919
908
|
|
|
920
909
|
it("should understand logical operators", () => {
|
|
921
|
-
|
|
910
|
+
["||", "&&"].forEach((operator) => {
|
|
922
911
|
expect(createAst(`foo${operator}bar`)).toEqual({
|
|
923
912
|
type: ASTType.Program,
|
|
924
913
|
body: [
|
|
@@ -937,7 +926,7 @@ describe("parser", () => {
|
|
|
937
926
|
});
|
|
938
927
|
|
|
939
928
|
it("should associate logical operators left-to-right", () => {
|
|
940
|
-
|
|
929
|
+
["||", "&&"].forEach((op) => {
|
|
941
930
|
expect(createAst(`foo${op}bar${op}baz`)).toEqual({
|
|
942
931
|
type: ASTType.Program,
|
|
943
932
|
body: [
|
|
@@ -1053,7 +1042,7 @@ describe("parser", () => {
|
|
|
1053
1042
|
});
|
|
1054
1043
|
|
|
1055
1044
|
it("should give higher precedence to equality than to the logical `and` operator", () => {
|
|
1056
|
-
|
|
1045
|
+
["==", "!=", "===", "!=="].forEach((operator) => {
|
|
1057
1046
|
expect(createAst(`foo${operator}bar && man${operator}shell`)).toEqual({
|
|
1058
1047
|
type: ASTType.Program,
|
|
1059
1048
|
body: [
|
|
@@ -1775,7 +1764,7 @@ describe("parser", () => {
|
|
|
1775
1764
|
});
|
|
1776
1765
|
});
|
|
1777
1766
|
|
|
1778
|
-
|
|
1767
|
+
[true, false].forEach((cspEnabled) => {
|
|
1779
1768
|
describe(`csp: ${cspEnabled}`, () => {
|
|
1780
1769
|
beforeEach(() => {
|
|
1781
1770
|
createInjector([
|
|
@@ -2016,7 +2005,7 @@ describe("parser", () => {
|
|
|
2016
2005
|
expect(scope.$eval("a.b.c.d.e.f.g.h.i.j.k.l.m.n", scope)).toBe("nooo!");
|
|
2017
2006
|
});
|
|
2018
2007
|
|
|
2019
|
-
|
|
2008
|
+
[2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 42, 99].forEach((pathLength) => {
|
|
2020
2009
|
it(`should resolve nested paths of length ${pathLength}`, () => {
|
|
2021
2010
|
// Create a nested object {x2: {x3: {x4: ... {x[n]: 42} ... }}}.
|
|
2022
2011
|
let obj = 42;
|
|
@@ -2397,23 +2386,20 @@ describe("parser", () => {
|
|
|
2397
2386
|
|
|
2398
2387
|
it("should throw TypeError on using a 'broken' object as a key to access a property", () => {
|
|
2399
2388
|
scope.object = {};
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
{
|
|
2405
|
-
|
|
2406
|
-
return {};
|
|
2407
|
-
},
|
|
2389
|
+
[
|
|
2390
|
+
{ toString: 2 },
|
|
2391
|
+
{ toString: null },
|
|
2392
|
+
{
|
|
2393
|
+
toString() {
|
|
2394
|
+
return {};
|
|
2408
2395
|
},
|
|
2409
|
-
],
|
|
2410
|
-
(brokenObject) => {
|
|
2411
|
-
scope.brokenObject = brokenObject;
|
|
2412
|
-
expect(() => {
|
|
2413
|
-
scope.$eval("object[brokenObject]");
|
|
2414
|
-
}).toThrow();
|
|
2415
2396
|
},
|
|
2416
|
-
)
|
|
2397
|
+
].forEach((brokenObject) => {
|
|
2398
|
+
scope.brokenObject = brokenObject;
|
|
2399
|
+
expect(() => {
|
|
2400
|
+
scope.$eval("object[brokenObject]");
|
|
2401
|
+
}).toThrow();
|
|
2402
|
+
});
|
|
2417
2403
|
});
|
|
2418
2404
|
|
|
2419
2405
|
it("should support method calls on primitive types", () => {
|