@angular-wave/angular.ts 0.8.0 → 0.8.2
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/@types/angular.d.ts +3 -3
- package/@types/core/compile/compile.d.ts +5 -2
- package/@types/core/di/ng-module.d.ts +61 -25
- package/@types/interface.d.ts +1 -1
- package/@types/router/directives/state-directives.d.ts +2 -2
- package/@types/router/directives/view-directive.d.ts +1 -1
- package/@types/router/params/param-type.d.ts +0 -1
- package/@types/router/{globals.d.ts → router.d.ts} +1 -1
- package/@types/router/state/state-registry.d.ts +2 -2
- package/@types/router/state/state-service.d.ts +6 -9
- package/@types/router/transition/transition-service.d.ts +3 -3
- package/@types/router/transition/transition.d.ts +4 -4
- package/@types/router/url/url-matcher.d.ts +0 -1
- package/@types/router/url/url-rule.d.ts +13 -4
- package/@types/router/url/url-service.d.ts +2 -2
- package/@types/shared/hof.d.ts +0 -6
- package/CHANGELOG.md +0 -72
- package/CONTRIBUTING.md +0 -1
- package/DEVELOPERS.md +0 -1
- package/TRIAGING.md +0 -1
- package/dist/angular-ts.esm.js +103 -103
- package/dist/angular-ts.umd.js +103 -103
- package/dist/angular-ts.umd.min.js +1 -1
- package/docs/layouts/shortcodes/version.html +1 -1
- package/docs/static/typedoc/assets/hierarchy.js +1 -1
- package/docs/static/typedoc/assets/navigation.js +1 -1
- package/docs/static/typedoc/assets/search.js +1 -1
- package/docs/static/typedoc/assets/style.css +2 -9
- package/docs/static/typedoc/classes/NgModule.html +3 -3
- package/docs/static/typedoc/types/Injectable.html +4 -1
- package/docs/static/typedoc/types/InjectableFactory.html +1 -4
- package/package.json +2 -2
- package/src/angular.js +10 -10
- package/src/angular.spec.js +4 -4
- package/src/core/compile/compile.js +1 -1
- package/src/core/di/ng-module.js +26 -21
- package/src/core/parse/parse.spec.js +29 -30
- package/src/directive/events/event.spec.js +5 -5
- package/src/directive/messages/messages.md +0 -4
- package/src/directive/repeat/repeat.js +1 -1
- package/src/injection-tokens.js +2 -2
- package/src/interface.ts +1 -2
- package/src/ng.js +5 -5
- package/src/ng.spec.js +1 -1
- package/src/router/directives/state-directives.js +5 -5
- package/src/router/directives/state-directives.spec.js +2 -2
- package/src/router/directives/view-directive.js +5 -5
- package/src/router/directives/view-directive.spec.js +20 -20
- package/src/router/params/param-type.js +0 -1
- package/src/router/params/param.js +1 -1
- package/src/router/{globals.js → router.js} +1 -1
- package/src/router/services.spec.js +3 -3
- package/src/router/state/state-registry.js +2 -2
- package/src/router/state/state-service.js +5 -8
- package/src/router/template-factory.spec.js +6 -6
- package/src/router/transition/transition-service.js +2 -2
- package/src/router/transition/transition.js +2 -2
- package/src/router/url/url-matcher.js +9 -11
- package/src/router/url/url-rule.js +7 -2
- package/src/router/url/url-service.js +6 -3
- package/src/router/url/url-service.spec.js +6 -39
- package/src/router/view-scroll.js +3 -1
- package/src/router/view-scroll.spec.js +11 -11
- package/src/services/location/location.js +9 -2
- package/src/services/location/location.spec.js +6 -0
- package/src/shared/common.js +5 -5
- package/src/shared/hof.js +0 -14
- package/src/shared/min-err.spec.js +1 -1
- package/src/shared/url-utils/url-utils.spec.js +0 -1
- package/src/shared/utils.spec.js +4 -4
- package/tsconfig.json +1 -7
|
@@ -13,14 +13,14 @@ describe("router services", () => {
|
|
|
13
13
|
(
|
|
14
14
|
$urlProvider,
|
|
15
15
|
$stateRegistryProvider,
|
|
16
|
-
$
|
|
16
|
+
$routerProvider,
|
|
17
17
|
$transitionsProvider,
|
|
18
18
|
$stateProvider,
|
|
19
19
|
) => {
|
|
20
20
|
providers = {
|
|
21
21
|
$urlProvider,
|
|
22
22
|
$stateRegistryProvider,
|
|
23
|
-
$
|
|
23
|
+
$routerProvider,
|
|
24
24
|
$transitionsProvider,
|
|
25
25
|
$stateProvider,
|
|
26
26
|
};
|
|
@@ -43,7 +43,7 @@ describe("router services", () => {
|
|
|
43
43
|
it("Should expose ng-router services from the UIRouter instance", () => {
|
|
44
44
|
expect($injector.get("$url")).toBeDefined();
|
|
45
45
|
expect($injector.get("$stateRegistry")).toBeDefined();
|
|
46
|
-
expect($injector.get("$
|
|
46
|
+
expect($injector.get("$router")).toBeDefined();
|
|
47
47
|
expect($injector.get("$transitions")).toBeDefined();
|
|
48
48
|
expect($injector.get("$state")).toBeDefined();
|
|
49
49
|
expect($injector.get("$view")).toBeDefined();
|
|
@@ -19,14 +19,14 @@ export class StateRegistryProvider {
|
|
|
19
19
|
/* @ignore */ static $inject = provider([
|
|
20
20
|
$injectTokens.$url,
|
|
21
21
|
$injectTokens.$state,
|
|
22
|
-
$injectTokens.$
|
|
22
|
+
$injectTokens.$router,
|
|
23
23
|
$injectTokens.$view,
|
|
24
24
|
]);
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* @param urlService
|
|
28
28
|
* @param stateService
|
|
29
|
-
* @param {import('../
|
|
29
|
+
* @param {import('../router.js').Router} globals
|
|
30
30
|
* @param viewService
|
|
31
31
|
*/
|
|
32
32
|
constructor(urlService, stateService, globals, viewService) {
|
|
@@ -30,7 +30,7 @@ export class StateProvider {
|
|
|
30
30
|
/**
|
|
31
31
|
* The latest successful state parameters
|
|
32
32
|
*
|
|
33
|
-
* @deprecated This is a passthrough through to [[
|
|
33
|
+
* @deprecated This is a passthrough through to [[Router.params]]
|
|
34
34
|
*/
|
|
35
35
|
get params() {
|
|
36
36
|
return this.globals.params;
|
|
@@ -38,7 +38,7 @@ export class StateProvider {
|
|
|
38
38
|
/**
|
|
39
39
|
* The current [[StateDeclaration]]
|
|
40
40
|
*
|
|
41
|
-
* @deprecated This is a passthrough through to [[
|
|
41
|
+
* @deprecated This is a passthrough through to [[Router.current]]
|
|
42
42
|
*/
|
|
43
43
|
get current() {
|
|
44
44
|
return this.globals.current;
|
|
@@ -46,21 +46,18 @@ export class StateProvider {
|
|
|
46
46
|
/**
|
|
47
47
|
* The current [[StateObject]] (an internal API)
|
|
48
48
|
*
|
|
49
|
-
* @deprecated This is a passthrough through to [[
|
|
49
|
+
* @deprecated This is a passthrough through to [[Router.$current]]
|
|
50
50
|
*/
|
|
51
51
|
get $current() {
|
|
52
52
|
return this.globals.$current;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
/* @ignore */ static $inject = [
|
|
56
|
-
"$routerGlobalsProvider",
|
|
57
|
-
"$transitionsProvider",
|
|
58
|
-
];
|
|
55
|
+
/* @ignore */ static $inject = ["$routerProvider", "$transitionsProvider"];
|
|
59
56
|
|
|
60
57
|
// Needs access to urlService, stateRegistry
|
|
61
58
|
/**
|
|
62
59
|
*
|
|
63
|
-
* @param {import('../
|
|
60
|
+
* @param {import('../router.js').Router} globals
|
|
64
61
|
* @param {*} transitionService
|
|
65
62
|
*/
|
|
66
63
|
constructor(globals, transitionService) {
|
|
@@ -78,9 +78,9 @@ describe("templateFactory", () => {
|
|
|
78
78
|
]);
|
|
79
79
|
$injector.invoke(
|
|
80
80
|
(_$templateFactory_, _$httpBackend_, _$sce_, $rootScope) => {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
$templateFactory = _$templateFactory_;
|
|
82
|
+
$httpBackend = _$httpBackend_;
|
|
83
|
+
$sce = _$sce_;
|
|
84
84
|
$scope = $rootScope;
|
|
85
85
|
},
|
|
86
86
|
);
|
|
@@ -119,9 +119,9 @@ describe("templateFactory", () => {
|
|
|
119
119
|
_$state_,
|
|
120
120
|
_$compile_,
|
|
121
121
|
) => {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
$templateFactory = _$templateFactory_;
|
|
123
|
+
$httpBackend = _$httpBackend_;
|
|
124
|
+
$sce = _$sce_;
|
|
125
125
|
$scope = $rootScope;
|
|
126
126
|
$stateRegistry = _$stateRegistry_;
|
|
127
127
|
$stateService = _$state_;
|
|
@@ -62,10 +62,10 @@ export let defaultTransOpts = {
|
|
|
62
62
|
* This API is located at `router.transitionService` ([[UIRouter.transitionService]])
|
|
63
63
|
*/
|
|
64
64
|
export class TransitionProvider {
|
|
65
|
-
/* @ignore */ static $inject = provider([$t.$
|
|
65
|
+
/* @ignore */ static $inject = provider([$t.$router, $t.$view]);
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
|
-
* @param {import('../
|
|
68
|
+
* @param {import('../router.js').Router} globals
|
|
69
69
|
* @param viewService
|
|
70
70
|
*/
|
|
71
71
|
constructor(globals, viewService) {
|
|
@@ -44,11 +44,11 @@ export class Transition {
|
|
|
44
44
|
* encapsulates the "from state".
|
|
45
45
|
* @param {import('../state/target-state.js').TargetState} targetState The target state and parameters being transitioned to (also, the transition options)
|
|
46
46
|
* @param {import('../transition/transition-service.js').TransitionProvider} transitionService The [[TransitionService]] instance
|
|
47
|
-
* @param {import('../
|
|
47
|
+
* @param {import('../router.js').Router} globals
|
|
48
48
|
*/
|
|
49
49
|
constructor(fromPath, targetState, transitionService, globals) {
|
|
50
50
|
/**
|
|
51
|
-
* @type {import('../
|
|
51
|
+
* @type {import('../router.js').Router}
|
|
52
52
|
*/
|
|
53
53
|
this.globals = globals;
|
|
54
54
|
this.transitionService = transitionService;
|
|
@@ -93,13 +93,6 @@ const defaultConfig = {
|
|
|
93
93
|
*
|
|
94
94
|
*/
|
|
95
95
|
export class UrlMatcher {
|
|
96
|
-
static encodeDashes(str) {
|
|
97
|
-
// Replace dashes with encoded "\-"
|
|
98
|
-
return encodeURIComponent(str).replace(
|
|
99
|
-
/-/g,
|
|
100
|
-
(c) => `%5C%${c.charCodeAt(0).toString(16).toUpperCase()}`,
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
96
|
/** @internal Given a matcher, return an array with the matcher's path segments and path params, in order */
|
|
104
97
|
static pathSegmentsAndParams(matcher) {
|
|
105
98
|
const staticSegments = matcher._segments;
|
|
@@ -310,9 +303,6 @@ export class UrlMatcher {
|
|
|
310
303
|
return this.pattern;
|
|
311
304
|
}
|
|
312
305
|
_getDecodedParamValue(value, param) {
|
|
313
|
-
if (isDefined(value)) {
|
|
314
|
-
value = param.type.decode(value);
|
|
315
|
-
}
|
|
316
306
|
return param.value(value);
|
|
317
307
|
}
|
|
318
308
|
/**
|
|
@@ -503,7 +493,7 @@ export class UrlMatcher {
|
|
|
503
493
|
if (encoded == null) return acc;
|
|
504
494
|
// If this parameter value is an array, encode the value using encodeDashes
|
|
505
495
|
if (Array.isArray(encoded))
|
|
506
|
-
return acc + map(encoded,
|
|
496
|
+
return acc + map(encoded, encodeDashes).join("-");
|
|
507
497
|
// If the parameter type is "raw", then do not encodeURIComponent
|
|
508
498
|
if (param.raw) return acc + encoded;
|
|
509
499
|
// Encode the value
|
|
@@ -532,3 +522,11 @@ export class UrlMatcher {
|
|
|
532
522
|
}
|
|
533
523
|
|
|
534
524
|
UrlMatcher.nameValidator = /^\w+([-.]+\w+)*(?:\[\])?$/;
|
|
525
|
+
|
|
526
|
+
function encodeDashes(str) {
|
|
527
|
+
// Replace dashes with encoded "\-"
|
|
528
|
+
return encodeURIComponent(str).replace(
|
|
529
|
+
/-/g,
|
|
530
|
+
(c) => `%5C%${c.charCodeAt(0).toString(16).toUpperCase()}`,
|
|
531
|
+
);
|
|
532
|
+
}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
isUndefined,
|
|
7
7
|
assert,
|
|
8
8
|
} from "../../shared/utils.js";
|
|
9
|
-
import { is,
|
|
9
|
+
import { is, pattern } from "../../shared/hof.js";
|
|
10
10
|
import { StateObject } from "../state/state-object.js";
|
|
11
11
|
/**
|
|
12
12
|
* Creates a [[UrlRule]]
|
|
@@ -19,6 +19,11 @@ import { StateObject } from "../state/state-object.js";
|
|
|
19
19
|
* - [[StateObject]]
|
|
20
20
|
*/
|
|
21
21
|
export class UrlRuleFactory {
|
|
22
|
+
/**
|
|
23
|
+
* @param {import('../url/url-service.js').UrlService} urlService
|
|
24
|
+
* @param {import('../state/state-service.js').StateProvider} stateService
|
|
25
|
+
* @param {import('../router.js').Router} routerGlobals
|
|
26
|
+
*/
|
|
22
27
|
constructor(urlService, stateService, routerGlobals) {
|
|
23
28
|
this.urlService = urlService;
|
|
24
29
|
this.stateService = stateService;
|
|
@@ -37,7 +42,7 @@ export class UrlRuleFactory {
|
|
|
37
42
|
[isString, (_what) => makeRule(this.urlService.compile(_what))],
|
|
38
43
|
[is(UrlMatcher), (_what) => this.fromUrlMatcher(_what, handler)],
|
|
39
44
|
[
|
|
40
|
-
|
|
45
|
+
(...args) => isState(...args) || isStateDeclaration(...args),
|
|
41
46
|
(_what) => this.fromState(_what, this.stateService, this.routerGlobals),
|
|
42
47
|
],
|
|
43
48
|
[is(RegExp), (_what) => this.fromRegExp(_what, handler)],
|
|
@@ -22,7 +22,7 @@ export class UrlService {
|
|
|
22
22
|
static $inject = provider([
|
|
23
23
|
$t.$location,
|
|
24
24
|
$t.$state,
|
|
25
|
-
$t.$
|
|
25
|
+
$t.$router,
|
|
26
26
|
$t.$urlConfig,
|
|
27
27
|
]);
|
|
28
28
|
|
|
@@ -32,7 +32,7 @@ export class UrlService {
|
|
|
32
32
|
/**
|
|
33
33
|
* @param {import("../../services/location/location").LocationProvider} $locationProvider
|
|
34
34
|
* @param {import("../../router/state/state-service.js").StateProvider} stateService
|
|
35
|
-
* @param {import("
|
|
35
|
+
* @param {import("../router.js").Router} globals
|
|
36
36
|
* @param {import("../../router/url/url-config.js").UrlConfigProvider} urlConfigProvider
|
|
37
37
|
*/
|
|
38
38
|
constructor($locationProvider, stateService, globals, urlConfigProvider) {
|
|
@@ -175,7 +175,10 @@ export class UrlService {
|
|
|
175
175
|
* @return the url (after potentially being processed)
|
|
176
176
|
*/
|
|
177
177
|
url(newUrl, state) {
|
|
178
|
-
if (isDefined(newUrl))
|
|
178
|
+
if (isDefined(newUrl)) {
|
|
179
|
+
const decodeUri = decodeURIComponent(newUrl);
|
|
180
|
+
this.$location.setUrl(decodeUri);
|
|
181
|
+
}
|
|
179
182
|
if (state) this.$location.setState(state);
|
|
180
183
|
return this.$location.getUrl();
|
|
181
184
|
}
|
|
@@ -10,7 +10,12 @@ describe("UrlMatcher", () => {
|
|
|
10
10
|
beforeEach(() => {
|
|
11
11
|
dealoc(document.getElementById("app"));
|
|
12
12
|
window.angular = new Angular();
|
|
13
|
-
window.angular
|
|
13
|
+
window.angular
|
|
14
|
+
.module("defaultModule", [])
|
|
15
|
+
.config(
|
|
16
|
+
($locationProvider) =>
|
|
17
|
+
($locationProvider.html5ModeConf.enabled = false),
|
|
18
|
+
);
|
|
14
19
|
$injector = window.angular.bootstrap(document.getElementById("app"), [
|
|
15
20
|
"defaultModule",
|
|
16
21
|
]);
|
|
@@ -80,44 +85,6 @@ describe("UrlMatcher", () => {
|
|
|
80
85
|
expect(matcher.format(array)).toBe("/?foo=bar&foo=baz");
|
|
81
86
|
});
|
|
82
87
|
|
|
83
|
-
it("should encode and decode slashes in parameter values as ~2F", () => {
|
|
84
|
-
const matcher1 = $url.compile("/:foo");
|
|
85
|
-
|
|
86
|
-
expect(matcher1.format({ foo: "/" })).toBe("/~2F");
|
|
87
|
-
expect(matcher1.format({ foo: "//" })).toBe("/~2F~2F");
|
|
88
|
-
|
|
89
|
-
expect(matcher1.exec("/")).toBeTruthy();
|
|
90
|
-
expect(matcher1.exec("//")).not.toBeTruthy();
|
|
91
|
-
|
|
92
|
-
expect(matcher1.exec("/").foo).toBe("");
|
|
93
|
-
expect(matcher1.exec("/123").foo).toBe("123");
|
|
94
|
-
expect(matcher1.exec("/~2F").foo).toBe("/");
|
|
95
|
-
expect(matcher1.exec("/123~2F").foo).toBe("123/");
|
|
96
|
-
|
|
97
|
-
// param :foo should match between two slashes
|
|
98
|
-
const matcher2 = $url.compile("/:foo/");
|
|
99
|
-
|
|
100
|
-
expect(matcher2.exec("/")).not.toBeTruthy();
|
|
101
|
-
expect(matcher2.exec("//")).toBeTruthy();
|
|
102
|
-
|
|
103
|
-
expect(matcher2.exec("//").foo).toBe("");
|
|
104
|
-
expect(matcher2.exec("/123/").foo).toBe("123");
|
|
105
|
-
expect(matcher2.exec("/~2F/").foo).toBe("/");
|
|
106
|
-
expect(matcher2.exec("/123~2F/").foo).toBe("123/");
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it("should encode and decode tildes in parameter values as ~~", () => {
|
|
110
|
-
const matcher1 = $url.compile("/:foo");
|
|
111
|
-
|
|
112
|
-
expect(matcher1.format({ foo: "abc" })).toBe("/abc");
|
|
113
|
-
expect(matcher1.format({ foo: "~abc" })).toBe("/~~abc");
|
|
114
|
-
expect(matcher1.format({ foo: "~2F" })).toBe("/~~2F");
|
|
115
|
-
|
|
116
|
-
expect(matcher1.exec("/abc").foo).toBe("abc");
|
|
117
|
-
expect(matcher1.exec("/~~abc").foo).toBe("~abc");
|
|
118
|
-
expect(matcher1.exec("/~~2F").foo).toBe("~2F");
|
|
119
|
-
});
|
|
120
|
-
|
|
121
88
|
describe("snake-case parameters", () => {
|
|
122
89
|
it("should match if properly formatted", () => {
|
|
123
90
|
const matcher = $url.compile(
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { $injectTokens as $t } from "../injection-tokens.js";
|
|
2
|
+
|
|
1
3
|
export class ViewScrollProvider {
|
|
2
4
|
constructor() {
|
|
3
5
|
this.enabled = false;
|
|
@@ -8,7 +10,7 @@ export class ViewScrollProvider {
|
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
$get = [
|
|
11
|
-
|
|
13
|
+
$t.$anchorScroll,
|
|
12
14
|
/**
|
|
13
15
|
* @param {import('../services/anchor-scroll.js').AnchorScrollObject} $anchorScroll
|
|
14
16
|
* @returns {import('../services/anchor-scroll.js').AnchorScrollObject|Function}
|
|
@@ -4,7 +4,7 @@ import { wait } from "../shared/test-utils.js";
|
|
|
4
4
|
|
|
5
5
|
describe("ngView", () => {
|
|
6
6
|
describe("scrollIntoView", () => {
|
|
7
|
-
let elem, $anchorScroll, $
|
|
7
|
+
let elem, $anchorScroll, $viewScroll;
|
|
8
8
|
|
|
9
9
|
beforeEach(() => {
|
|
10
10
|
dealoc(document.getElementById("app"));
|
|
@@ -14,15 +14,15 @@ describe("ngView", () => {
|
|
|
14
14
|
"defaultModule",
|
|
15
15
|
]);
|
|
16
16
|
|
|
17
|
-
$injector.invoke((_$
|
|
17
|
+
$injector.invoke((_$viewScroll_, _$anchorScroll_) => {
|
|
18
18
|
$anchorScroll = _$anchorScroll_;
|
|
19
|
-
$
|
|
19
|
+
$viewScroll = _$viewScroll_;
|
|
20
20
|
});
|
|
21
21
|
elem = [{ scrollIntoView: jasmine.createSpy("scrollIntoView") }];
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
it("should scroll element into view after timeout", async () => {
|
|
25
|
-
$
|
|
25
|
+
$viewScroll(elem[0]);
|
|
26
26
|
expect(elem[0].scrollIntoView).not.toHaveBeenCalled();
|
|
27
27
|
|
|
28
28
|
await wait(100);
|
|
@@ -31,7 +31,7 @@ describe("ngView", () => {
|
|
|
31
31
|
|
|
32
32
|
it("should return the promise from the timeout", async () => {
|
|
33
33
|
dealoc(document.getElementById("app"));
|
|
34
|
-
const promise = $
|
|
34
|
+
const promise = $viewScroll(elem[0]);
|
|
35
35
|
|
|
36
36
|
await wait(10);
|
|
37
37
|
expect(elem[0].scrollIntoView).toHaveBeenCalled();
|
|
@@ -40,32 +40,32 @@ describe("ngView", () => {
|
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
describe("useAnchorScroll", () => {
|
|
43
|
-
let elem, $anchorScroll, $
|
|
43
|
+
let elem, $anchorScroll, $viewScroll;
|
|
44
44
|
|
|
45
45
|
beforeEach(() => {
|
|
46
46
|
dealoc(document.getElementById("app"));
|
|
47
47
|
window.angular = new Angular();
|
|
48
48
|
let module = window.angular.module("defaultModule", []);
|
|
49
|
-
module.config(($provide, $
|
|
49
|
+
module.config(($provide, $viewScrollProvider) => {
|
|
50
50
|
$provide.decorator("$anchorScroll", function ($delegate) {
|
|
51
51
|
return jasmine.createSpy("$anchorScroll");
|
|
52
52
|
});
|
|
53
|
-
$
|
|
53
|
+
$viewScrollProvider.useAnchorScroll();
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
let $injector = window.angular.bootstrap(document.getElementById("app"), [
|
|
57
57
|
"defaultModule",
|
|
58
58
|
]);
|
|
59
59
|
|
|
60
|
-
$injector.invoke((_$
|
|
60
|
+
$injector.invoke((_$viewScroll_, _$anchorScroll_) => {
|
|
61
61
|
$anchorScroll = _$anchorScroll_;
|
|
62
|
-
$
|
|
62
|
+
$viewScroll = _$viewScroll_;
|
|
63
63
|
});
|
|
64
64
|
elem = [{ scrollIntoView: jasmine.createSpy("scrollIntoView") }];
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
it("should call $anchorScroll", () => {
|
|
68
|
-
$
|
|
68
|
+
$viewScroll();
|
|
69
69
|
expect($anchorScroll).toHaveBeenCalled();
|
|
70
70
|
});
|
|
71
71
|
});
|
|
@@ -92,8 +92,15 @@ export class Location {
|
|
|
92
92
|
*/
|
|
93
93
|
setUrl(url) {
|
|
94
94
|
const match = PATH_MATCH.exec(url);
|
|
95
|
-
|
|
96
|
-
if (match[
|
|
95
|
+
|
|
96
|
+
if (match[1] !== undefined || url === "") {
|
|
97
|
+
this.setPath(match[1] || "");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (match[2] !== undefined || match[1] !== undefined || url === "") {
|
|
101
|
+
this.setSearch(match[3] || "");
|
|
102
|
+
}
|
|
103
|
+
|
|
97
104
|
this.setHash(match[5] || "");
|
|
98
105
|
|
|
99
106
|
return this;
|
|
@@ -529,6 +529,12 @@ describe("$location", () => {
|
|
|
529
529
|
locationUrl.setSearch({ "a+b": "c+d" });
|
|
530
530
|
expect(locationUrl.getSearch()).toEqual({ "a+b": "c+d" });
|
|
531
531
|
});
|
|
532
|
+
|
|
533
|
+
fit("should not drop encodings on already enconded params", () => {
|
|
534
|
+
const locationUrl = createLocationHtml5Url();
|
|
535
|
+
locationUrl.setUrl("/path/foo%2Fbar/baz%2Fqux");
|
|
536
|
+
expect(locationUrl.getPath()).toEqual("/path/foo%2Fbar/baz%2Fqux");
|
|
537
|
+
});
|
|
532
538
|
});
|
|
533
539
|
});
|
|
534
540
|
|
package/src/shared/common.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isDate, isFunction, isRegExp, isString } from "./utils.js";
|
|
2
|
-
import {
|
|
2
|
+
import { curry } from "./hof.js";
|
|
3
3
|
|
|
4
4
|
export function equals(o1, o2) {
|
|
5
5
|
if (o1 === o2) return true;
|
|
@@ -9,10 +9,10 @@ export function equals(o1, o2) {
|
|
|
9
9
|
t2 = typeof o2;
|
|
10
10
|
if (t1 !== t2 || t1 !== "object") return false;
|
|
11
11
|
const tup = [o1, o2];
|
|
12
|
-
if (
|
|
13
|
-
if (
|
|
14
|
-
if (
|
|
15
|
-
if (
|
|
12
|
+
if (tup.every(Array.isArray)) return _arraysEq(o1, o2);
|
|
13
|
+
if (tup.every(isDate)) return o1.getTime() === o2.getTime();
|
|
14
|
+
if (tup.every(isRegExp)) return o1.toString() === o2.toString();
|
|
15
|
+
if (tup.every(isFunction)) return true; // meh
|
|
16
16
|
if ([isFunction, Array.isArray, isDate, isRegExp].some((fn) => !!fn(tup))) {
|
|
17
17
|
return false;
|
|
18
18
|
}
|
package/src/shared/hof.js
CHANGED
|
@@ -96,20 +96,6 @@ export const parse = (name) =>
|
|
|
96
96
|
name.split(".").map((name) => (obj) => obj && obj[name]),
|
|
97
97
|
);
|
|
98
98
|
|
|
99
|
-
/**
|
|
100
|
-
* Given two functions that return truthy or falsey values, returns a function that returns truthy
|
|
101
|
-
* if at least one of the functions returns truthy for the given arguments
|
|
102
|
-
*/
|
|
103
|
-
export function or(fn1, fn2) {
|
|
104
|
-
return (...args) => fn1.apply(null, args) || fn2.apply(null, args);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Check if all the elements of an array match a predicate function
|
|
108
|
-
*
|
|
109
|
-
* @param fn1 a predicate function `fn1`
|
|
110
|
-
* @returns a function which takes an array and returns true if `fn1` is true for all elements of the array
|
|
111
|
-
*/
|
|
112
|
-
export const all = (fn1) => (arr) => arr.reduce((b, x) => b && !!fn1(x), true);
|
|
113
99
|
/** Given a class, returns a Predicate function that returns true if the object is of that class */
|
|
114
100
|
export const is = (ctor) => (obj) =>
|
|
115
101
|
(obj != null && obj.constructor === ctor) || obj instanceof ctor;
|
|
@@ -10,7 +10,6 @@ describe("urlUtils", () => {
|
|
|
10
10
|
it("should returned already parsed URLs unchanged", () => {
|
|
11
11
|
const urlObj = urlResolve("/foo?bar=baz#qux");
|
|
12
12
|
expect(urlResolve(urlObj)).toBe(urlObj);
|
|
13
|
-
expect(urlResolve(true)).toBe(true);
|
|
14
13
|
expect(urlResolve(null)).toBeNull();
|
|
15
14
|
expect(urlResolve(undefined)).toBeUndefined();
|
|
16
15
|
});
|
package/src/shared/utils.spec.js
CHANGED
|
@@ -123,22 +123,22 @@ describe("api", () => {
|
|
|
123
123
|
});
|
|
124
124
|
|
|
125
125
|
it("uses preassigned $$hashKey", () => {
|
|
126
|
-
expect(hashKey({ $$hashKey: 42 })).toEqual(42);
|
|
126
|
+
expect(hashKey({ $$hashKey: "42" })).toEqual("42");
|
|
127
127
|
});
|
|
128
128
|
|
|
129
129
|
it("supports a function $$hashKey", function () {
|
|
130
|
-
expect(hashKey({ $$hashKey: () => 42 })).toEqual(42);
|
|
130
|
+
expect(hashKey({ $$hashKey: () => "42" })).toEqual("42");
|
|
131
131
|
});
|
|
132
132
|
|
|
133
133
|
it("calls the function $$hashKey as a method with the correct this", () => {
|
|
134
134
|
expect(
|
|
135
135
|
hashKey({
|
|
136
|
-
myKey: 42,
|
|
136
|
+
myKey: "42",
|
|
137
137
|
$$hashKey: function () {
|
|
138
138
|
return this.myKey;
|
|
139
139
|
},
|
|
140
140
|
}),
|
|
141
|
-
).toEqual(42);
|
|
141
|
+
).toEqual("42");
|
|
142
142
|
});
|
|
143
143
|
});
|
|
144
144
|
|
package/tsconfig.json
CHANGED
|
@@ -15,11 +15,5 @@
|
|
|
15
15
|
"typeRoots": ["node_modules/@types"]
|
|
16
16
|
},
|
|
17
17
|
"include": ["src"],
|
|
18
|
-
"exclude": [
|
|
19
|
-
"**/*.d.ts",
|
|
20
|
-
"node_modules",
|
|
21
|
-
"types/**",
|
|
22
|
-
"**/*.test.js",
|
|
23
|
-
"**/*.spec.js"
|
|
24
|
-
]
|
|
18
|
+
"exclude": ["**/*.d.ts", "node_modules", "**/*.spec.js", "**/*.test.js"]
|
|
25
19
|
}
|