@angular-wave/angular.ts 0.4.4 → 0.4.5
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 -12
- package/index.html +3 -74
- package/package.json +1 -1
- package/src/angular.spec.js +5 -0
- package/src/animations/animate-css.js +13 -5
- package/src/animations/animate-queue.js +21 -22
- package/src/animations/animate-runner.js +8 -4
- package/src/animations/animate.md +1 -1
- package/src/animations/animate.spec.js +21 -0
- package/src/animations/animation.js +1 -1
- package/src/binding.spec.js +1 -0
- package/src/core/compile/compile.js +26 -25
- package/src/core/compile/compile.spec.js +266 -17
- package/src/core/controller/controller.js +0 -2
- package/src/core/di/injector.md +1 -1
- package/src/core/di/injector.spec.js +2 -0
- package/src/core/di/internal-injector.js +1 -2
- package/src/core/interpolate/interpolate.js +3 -16
- package/src/core/interpolate/interpolate.spec.js +16 -70
- package/src/core/interval/interval-factory.js +50 -0
- package/src/core/interval/interval.html +18 -0
- package/src/core/interval/interval.js +77 -0
- package/src/core/interval/interval.md +123 -0
- package/src/core/interval/interval.spec.js +280 -0
- package/src/core/interval/interval.test.js +1 -1
- package/src/core/location/location.js +47 -39
- package/src/core/location/location.spec.js +27 -27
- package/src/core/on.spec.js +7 -0
- package/src/core/parse/interpreter.js +7 -10
- package/src/core/parse/parse.js +5 -26
- package/src/core/parse/parse.spec.js +91 -95
- package/src/core/prop.spec.js +60 -4
- package/src/core/q/q.html +18 -0
- package/src/core/q/q.js +472 -0
- package/src/core/q/q.md +211 -0
- package/src/core/q/q.spec.js +2748 -0
- package/src/core/q/q.test.js +12 -0
- package/src/core/sce/sce.spec.js +8 -0
- package/src/core/{model/model.html → scope/scope.html} +1 -1
- package/src/core/scope/scope.js +16 -15
- package/src/core/scope/scope.spec.js +1959 -24
- package/src/core/scope/scope.test.js +12 -0
- package/src/core/timeout/timeout.html +18 -0
- package/src/core/timeout/timeout.js +109 -0
- package/src/core/timeout/timeout.spec.js +354 -0
- package/src/core/timeout/timout.test.js +12 -0
- package/src/core/url-utils/url-utils.spec.js +1 -1
- package/src/directive/aria/aria.js +6 -3
- package/src/directive/aria/aria.spec.js +87 -0
- package/src/directive/attrs/attrs.spec.js +5 -0
- package/src/directive/attrs/boolean.spec.js +15 -0
- package/src/directive/attrs/element-style.spec.js +8 -0
- package/src/directive/attrs/src.spec.js +7 -0
- package/src/directive/bind/bind.spec.js +33 -0
- package/src/directive/bind/bing-html.spec.js +3 -0
- package/src/directive/class/class.js +3 -3
- package/src/directive/class/class.spec.js +75 -9
- package/src/directive/controller/controller.spec.js +13 -0
- package/src/directive/events/click.spec.js +3 -0
- package/src/directive/events/event.spec.js +6 -0
- package/src/directive/form/form.js +3 -2
- package/src/directive/form/form.spec.js +65 -0
- package/src/directive/if/if.spec.js +4 -0
- package/src/directive/include/include.spec.js +59 -8
- package/src/directive/init/init.js +2 -6
- package/src/directive/init/init.spec.js +2 -0
- package/src/directive/input/input.spec.js +136 -0
- package/src/directive/messages/messages.spec.js +35 -4
- package/src/directive/model/model.js +25 -18
- package/src/directive/model/model.spec.js +49 -2
- package/src/directive/model-options/model-options.spec.js +6 -0
- package/src/directive/non-bindable/non-bindable.spec.js +1 -0
- package/src/directive/observe/observe.js +1 -0
- package/src/directive/observe/observe.spec.js +1 -0
- package/src/directive/options/options.spec.js +34 -0
- package/src/directive/ref/href.spec.js +15 -0
- package/src/directive/repeat/repeat.spec.js +135 -8
- package/src/directive/script/script.spec.js +2 -0
- package/src/directive/select/select.js +3 -3
- package/src/directive/select/select.spec.js +96 -0
- package/src/directive/show-hide/show-hide.js +2 -2
- package/src/directive/show-hide/show-hide.spec.js +19 -8
- package/src/directive/style/style.spec.js +7 -0
- package/src/directive/switch/switch.spec.js +5 -5
- package/src/directive/validators/validators.spec.js +1 -0
- package/src/loader.js +1 -0
- package/src/public.js +10 -2
- package/src/router/common/coreservices.js +2 -0
- package/src/router/directives/state-directives.js +14 -6
- package/src/router/directives/state-directives.spec.js +83 -0
- package/src/router/directives/view-directive.js +13 -4
- package/src/router/directives/view-directive.spec.js +71 -25
- package/src/router/hooks/lazy-load.js +2 -2
- package/src/router/hooks/views.js +5 -3
- package/src/router/resolve/resolvable.js +6 -3
- package/src/router/resolve/resolve-context.js +2 -2
- package/src/router/state/state-service.js +4 -4
- package/src/router/state/state.spec.js +5 -2
- package/src/router/state/state.test.js +1 -1
- package/src/router/state/views.js +10 -7
- package/src/router/template-factory.js +6 -3
- package/src/router/template-factory.spec.js +4 -0
- package/src/router/transition/transition-hook.js +1 -1
- package/src/router/transition/transition.js +1 -1
- package/src/router/view-hook.spec.js +2 -2
- package/src/router/view-scroll.js +6 -4
- package/src/services/browser.js +5 -8
- package/src/services/http/http.js +9 -6
- package/src/services/http/http.spec.js +31 -30
- package/src/services/http/template-request.spec.js +10 -0
- package/src/services/http-backend/http-backend.spec.js +3 -3
- package/src/services/template-request.js +4 -2
- package/src/shared/common.js +2 -1
- package/types/core/location/location.d.ts +36 -31
- package/types/core/parse/parse.d.ts +0 -26
- package/types/core/scope/scope.d.ts +11 -11
- package/src/core/model/model.js +0 -944
- package/src/core/model/model.spec.js +0 -3012
- package/types/core/model/model.d.ts +0 -204
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { Angular } from "../../loader";
|
|
2
|
+
import { createInjector } from "../di/injector";
|
|
3
|
+
import { wait } from "../../shared/test-utils";
|
|
4
|
+
|
|
5
|
+
describe("$interval", () => {
|
|
6
|
+
let injector;
|
|
7
|
+
let $interval;
|
|
8
|
+
let $rootScope;
|
|
9
|
+
let errors;
|
|
10
|
+
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
errors = [];
|
|
13
|
+
window.angular = new Angular();
|
|
14
|
+
window.angular
|
|
15
|
+
.module("myModule", ["ng"])
|
|
16
|
+
.decorator("$exceptionHandler", () => {
|
|
17
|
+
return (exception) => {
|
|
18
|
+
errors.push(exception);
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
injector = createInjector(["myModule"]);
|
|
22
|
+
|
|
23
|
+
$interval = injector.get("$interval");
|
|
24
|
+
$rootScope = injector.get("$rootScope");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should run tasks repeatedly", async () => {
|
|
28
|
+
let counter = 0;
|
|
29
|
+
$interval(() => {
|
|
30
|
+
counter++;
|
|
31
|
+
}, 1);
|
|
32
|
+
expect(counter).toBe(0);
|
|
33
|
+
await wait(15);
|
|
34
|
+
expect(counter).toBeGreaterThanOrEqual(1);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("should call $apply after each task is executed", (done) => {
|
|
38
|
+
const applySpy = spyOn($rootScope, "$apply").and.callThrough();
|
|
39
|
+
|
|
40
|
+
$interval(() => {}, 1);
|
|
41
|
+
expect(applySpy).not.toHaveBeenCalled();
|
|
42
|
+
|
|
43
|
+
setTimeout(() => {
|
|
44
|
+
expect(applySpy).toHaveBeenCalled();
|
|
45
|
+
}, 3);
|
|
46
|
+
|
|
47
|
+
applySpy.calls.reset();
|
|
48
|
+
|
|
49
|
+
$interval(() => {}, 1);
|
|
50
|
+
$interval(() => {}, 1);
|
|
51
|
+
|
|
52
|
+
setTimeout(() => {
|
|
53
|
+
expect(applySpy).toHaveBeenCalledTimes(3);
|
|
54
|
+
done();
|
|
55
|
+
}, 1);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("should allow you to specify a number of iterations", async () => {
|
|
59
|
+
let counter = 0;
|
|
60
|
+
$interval(
|
|
61
|
+
() => {
|
|
62
|
+
counter++;
|
|
63
|
+
},
|
|
64
|
+
1,
|
|
65
|
+
2,
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
await wait(15);
|
|
69
|
+
expect(counter).toBe(2);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("should allow you to specify a number of arguments", (done) => {
|
|
73
|
+
const task1 = jasmine.createSpy("task1");
|
|
74
|
+
const task2 = jasmine.createSpy("task2");
|
|
75
|
+
const task3 = jasmine.createSpy("task3");
|
|
76
|
+
$interval(task1, 1, 2, true, "Task1");
|
|
77
|
+
$interval(task2, 1, 2, true, "Task2");
|
|
78
|
+
$interval(task3, 1, 2, true, "I", "am", "a", "Task3", "spy");
|
|
79
|
+
|
|
80
|
+
setTimeout(() => {
|
|
81
|
+
expect(task1).toHaveBeenCalledWith("Task1");
|
|
82
|
+
expect(task2).toHaveBeenCalledWith("Task2");
|
|
83
|
+
expect(task3).toHaveBeenCalledWith("I", "am", "a", "Task3", "spy");
|
|
84
|
+
}, 1);
|
|
85
|
+
|
|
86
|
+
task1.calls.reset();
|
|
87
|
+
task2.calls.reset();
|
|
88
|
+
task3.calls.reset();
|
|
89
|
+
|
|
90
|
+
setTimeout(() => {
|
|
91
|
+
expect(task1).toHaveBeenCalledWith("Task1");
|
|
92
|
+
expect(task2).toHaveBeenCalledWith("Task2");
|
|
93
|
+
expect(task3).toHaveBeenCalledWith("I", "am", "a", "Task3", "spy");
|
|
94
|
+
done();
|
|
95
|
+
}, 1);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("should return a promise which will be updated with the count on each iteration", async () => {
|
|
99
|
+
const log = [];
|
|
100
|
+
const promise = $interval(() => {
|
|
101
|
+
log.push("tick");
|
|
102
|
+
}, 1);
|
|
103
|
+
|
|
104
|
+
promise.then(
|
|
105
|
+
(value) => {
|
|
106
|
+
log.push(`promise success: ${value}`);
|
|
107
|
+
},
|
|
108
|
+
(err) => {
|
|
109
|
+
log.push(`promise error: ${err}`);
|
|
110
|
+
},
|
|
111
|
+
(note) => {
|
|
112
|
+
log.push(`promise update: ${note}`);
|
|
113
|
+
},
|
|
114
|
+
);
|
|
115
|
+
expect(log).toEqual([]);
|
|
116
|
+
|
|
117
|
+
await wait(5);
|
|
118
|
+
expect(log[0]).toEqual("tick");
|
|
119
|
+
expect(log[1]).toEqual("tick");
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("should return a promise which will be resolved after the specified number of iterations", async () => {
|
|
123
|
+
const log = [];
|
|
124
|
+
const promise = $interval(
|
|
125
|
+
() => {
|
|
126
|
+
log.push("tick");
|
|
127
|
+
},
|
|
128
|
+
1,
|
|
129
|
+
2,
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
promise.then(
|
|
133
|
+
(value) => {
|
|
134
|
+
log.push(`promise success: ${value}`);
|
|
135
|
+
},
|
|
136
|
+
(err) => {
|
|
137
|
+
log.push(`promise error: ${err}`);
|
|
138
|
+
},
|
|
139
|
+
);
|
|
140
|
+
expect(log).toEqual([]);
|
|
141
|
+
await wait(15);
|
|
142
|
+
expect(log).toEqual(["tick", "tick", "promise success: 2"]);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
describe("exception handling", () => {
|
|
146
|
+
it("should delegate exception to the $exceptionHandler service", (done) => {
|
|
147
|
+
errors = [];
|
|
148
|
+
$interval(() => {
|
|
149
|
+
throw "Test Error";
|
|
150
|
+
}, 10);
|
|
151
|
+
|
|
152
|
+
setTimeout(() => {
|
|
153
|
+
expect(errors).toContain("Test Error");
|
|
154
|
+
done();
|
|
155
|
+
}, 20);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("should call $apply even if an exception is thrown in callback", (done) => {
|
|
159
|
+
const applySpy = spyOn($rootScope, "$apply").and.callThrough();
|
|
160
|
+
|
|
161
|
+
$interval(() => {
|
|
162
|
+
throw "Test Error2";
|
|
163
|
+
}, 10);
|
|
164
|
+
expect(applySpy).not.toHaveBeenCalled();
|
|
165
|
+
|
|
166
|
+
setTimeout(() => {
|
|
167
|
+
expect(applySpy).toHaveBeenCalled();
|
|
168
|
+
done();
|
|
169
|
+
}, 11);
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
describe("cancel", () => {
|
|
174
|
+
it("should cancel tasks", (done) => {
|
|
175
|
+
const task1 = jasmine.createSpy("task1", 1);
|
|
176
|
+
const task2 = jasmine.createSpy("task2", 1);
|
|
177
|
+
const task3 = jasmine.createSpy("task3", 1);
|
|
178
|
+
let promise1;
|
|
179
|
+
let promise3;
|
|
180
|
+
|
|
181
|
+
promise1 = $interval(task1, 2);
|
|
182
|
+
$interval(task2, 1);
|
|
183
|
+
promise3 = $interval(task3, 3);
|
|
184
|
+
|
|
185
|
+
$interval.cancel(promise3);
|
|
186
|
+
$interval.cancel(promise1);
|
|
187
|
+
setTimeout(() => {
|
|
188
|
+
expect(task1).not.toHaveBeenCalled();
|
|
189
|
+
expect(task2).toHaveBeenCalled();
|
|
190
|
+
expect(task3).not.toHaveBeenCalled();
|
|
191
|
+
done();
|
|
192
|
+
}, 1);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it("should cancel the promise", (done) => {
|
|
196
|
+
const promise = $interval(() => {}, 1);
|
|
197
|
+
const log = [];
|
|
198
|
+
promise.then(
|
|
199
|
+
(value) => {
|
|
200
|
+
log.push(`promise success: ${value}`);
|
|
201
|
+
},
|
|
202
|
+
(err) => {
|
|
203
|
+
log.push(`promise error: ${err}`);
|
|
204
|
+
},
|
|
205
|
+
);
|
|
206
|
+
expect(log).toEqual([]);
|
|
207
|
+
|
|
208
|
+
setTimeout(() => {
|
|
209
|
+
$interval.cancel(promise);
|
|
210
|
+
}, 1);
|
|
211
|
+
|
|
212
|
+
setTimeout(() => {
|
|
213
|
+
$rootScope.$apply(); // For resolving the promise -
|
|
214
|
+
// necessary since q uses $rootScope.evalAsync.
|
|
215
|
+
|
|
216
|
+
expect(log).toEqual(["promise error: canceled"]);
|
|
217
|
+
done();
|
|
218
|
+
}, 2);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it("should return true if a task was successfully canceled", (done) => {
|
|
222
|
+
const task1 = jasmine.createSpy("task1");
|
|
223
|
+
const task2 = jasmine.createSpy("task2");
|
|
224
|
+
let promise1;
|
|
225
|
+
let promise2;
|
|
226
|
+
|
|
227
|
+
promise1 = $interval(task1, 1, 1);
|
|
228
|
+
setTimeout(() => {
|
|
229
|
+
promise2 = $interval(task2, 1, 1);
|
|
230
|
+
|
|
231
|
+
expect($interval.cancel(promise1)).toBe(false);
|
|
232
|
+
expect($interval.cancel(promise2)).toBe(true);
|
|
233
|
+
done();
|
|
234
|
+
}, 1);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it("should not throw an error when given an undefined promise", () => {
|
|
238
|
+
expect($interval.cancel()).toBe(false);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it("should throw an error when given a non-$interval promise", () => {
|
|
242
|
+
const promise = $interval(() => {}).then(() => {});
|
|
243
|
+
expect(() => {
|
|
244
|
+
$interval.cancel(promise);
|
|
245
|
+
}).toThrowError(/badprom/);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it("should not trigger digest when cancelled", () => {
|
|
249
|
+
const watchSpy = jasmine.createSpy("watchSpy");
|
|
250
|
+
$rootScope.$watch(watchSpy);
|
|
251
|
+
|
|
252
|
+
const t = $interval();
|
|
253
|
+
$interval.cancel(t);
|
|
254
|
+
expect(watchSpy).not.toHaveBeenCalled();
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
describe("$window delegation", () => {
|
|
259
|
+
it("should use $window.setInterval instead of the global function", () => {
|
|
260
|
+
const setIntervalSpy = spyOn(window, "setInterval");
|
|
261
|
+
|
|
262
|
+
$interval(() => {}, 1);
|
|
263
|
+
expect(setIntervalSpy).toHaveBeenCalled();
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
it("should use $window.clearInterval instead of the global function", (done) => {
|
|
267
|
+
const clearIntervalSpy = spyOn(window, "clearInterval");
|
|
268
|
+
|
|
269
|
+
$interval(() => {}, 1, 1);
|
|
270
|
+
setTimeout(() => {
|
|
271
|
+
expect(clearIntervalSpy).toHaveBeenCalled();
|
|
272
|
+
|
|
273
|
+
clearIntervalSpy.calls.reset();
|
|
274
|
+
$interval.cancel($interval(() => {}, 1));
|
|
275
|
+
expect(clearIntervalSpy).toHaveBeenCalled();
|
|
276
|
+
done();
|
|
277
|
+
}, 1);
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
});
|
|
@@ -5,7 +5,7 @@ const TEST_URL = "src/core/interval/interval.html";
|
|
|
5
5
|
test("unit tests contain no errors", async ({ page }) => {
|
|
6
6
|
await page.goto(TEST_URL);
|
|
7
7
|
await page.content();
|
|
8
|
-
await page.waitForTimeout(
|
|
8
|
+
await page.waitForTimeout(500);
|
|
9
9
|
await expect(page.locator(".jasmine-overall-result")).toHaveText(
|
|
10
10
|
/0 failures/,
|
|
11
11
|
);
|
|
@@ -2,7 +2,6 @@ import { JQLite } from "../../shared/jqlite/jqlite";
|
|
|
2
2
|
import { urlResolve } from "../url-utils/url-utils";
|
|
3
3
|
import {
|
|
4
4
|
encodeUriSegment,
|
|
5
|
-
isBoolean,
|
|
6
5
|
isDefined,
|
|
7
6
|
isNumber,
|
|
8
7
|
isObject,
|
|
@@ -13,6 +12,7 @@ import {
|
|
|
13
12
|
toInt,
|
|
14
13
|
toKeyValue,
|
|
15
14
|
} from "../../shared/utils";
|
|
15
|
+
import { ScopePhase } from "../scope/scope";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @typedef {Object} DefaultPorts
|
|
@@ -329,7 +329,6 @@ export class Location {
|
|
|
329
329
|
// so the modification window is narrow.
|
|
330
330
|
this.$$state = isUndefined(state) ? null : state;
|
|
331
331
|
this.$$urlUpdatedByLocation = true;
|
|
332
|
-
|
|
333
332
|
return this;
|
|
334
333
|
}
|
|
335
334
|
|
|
@@ -543,26 +542,28 @@ export class LocationHashbangUrl extends Location {
|
|
|
543
542
|
}
|
|
544
543
|
}
|
|
545
544
|
|
|
546
|
-
export
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
545
|
+
export class LocationProvider {
|
|
546
|
+
constructor() {
|
|
547
|
+
this.hashPrefixValue = "!";
|
|
548
|
+
this.html5ModeConfig = {
|
|
549
|
+
enabled: false,
|
|
550
|
+
requireBase: true,
|
|
551
|
+
rewriteLinks: true,
|
|
552
|
+
};
|
|
553
|
+
}
|
|
553
554
|
|
|
554
555
|
/**
|
|
555
556
|
* The default value for the prefix is `'!'`.
|
|
556
|
-
* @param {string=} prefix Prefix for hash part (containing path and search)
|
|
557
|
-
* @returns {
|
|
557
|
+
* @param {string=} prefix - Prefix for hash part (containing path and search)
|
|
558
|
+
* @returns {string|LocationProvider} current value if used as getter or itself (chaining) if used as setter
|
|
558
559
|
*/
|
|
559
|
-
|
|
560
|
-
if (
|
|
561
|
-
|
|
560
|
+
hashPrefix(prefix) {
|
|
561
|
+
if (typeof prefix !== "undefined") {
|
|
562
|
+
this.hashPrefixValue = prefix;
|
|
562
563
|
return this;
|
|
563
564
|
}
|
|
564
|
-
return
|
|
565
|
-
}
|
|
565
|
+
return this.hashPrefixValue;
|
|
566
|
+
}
|
|
566
567
|
|
|
567
568
|
/**
|
|
568
569
|
* @param {(boolean|Object)=} mode If boolean, sets `html5Mode.enabled` to value.
|
|
@@ -584,30 +585,29 @@ export function LocationProvider() {
|
|
|
584
585
|
*
|
|
585
586
|
* @returns {Object} html5Mode object if used as getter or itself (chaining) if used as setter
|
|
586
587
|
*/
|
|
587
|
-
|
|
588
|
-
if (
|
|
589
|
-
|
|
588
|
+
html5Mode(mode) {
|
|
589
|
+
if (typeof mode === "boolean") {
|
|
590
|
+
this.html5ModeConfig.enabled = mode;
|
|
590
591
|
return this;
|
|
591
592
|
}
|
|
592
|
-
if (isObject(mode)) {
|
|
593
|
-
if (isBoolean(mode.enabled)) {
|
|
594
|
-
html5Mode.enabled = mode.enabled;
|
|
595
|
-
}
|
|
596
593
|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
594
|
+
if (typeof mode === "object") {
|
|
595
|
+
if (typeof mode.enabled === "boolean")
|
|
596
|
+
this.html5ModeConfig.enabled = mode.enabled;
|
|
597
|
+
if (typeof mode.requireBase === "boolean")
|
|
598
|
+
this.html5ModeConfig.requireBase = mode.requireBase;
|
|
599
|
+
if (
|
|
600
|
+
typeof mode.rewriteLinks === "boolean" ||
|
|
601
|
+
typeof mode.rewriteLinks === "string"
|
|
602
|
+
) {
|
|
603
|
+
this.html5ModeConfig.rewriteLinks = mode.rewriteLinks;
|
|
603
604
|
}
|
|
604
|
-
|
|
605
605
|
return this;
|
|
606
606
|
}
|
|
607
|
-
return
|
|
608
|
-
}
|
|
607
|
+
return this.html5ModeConfig;
|
|
608
|
+
}
|
|
609
609
|
|
|
610
|
-
|
|
610
|
+
$get = [
|
|
611
611
|
"$rootScope",
|
|
612
612
|
"$browser",
|
|
613
613
|
"$rootElement",
|
|
@@ -626,8 +626,8 @@ export function LocationProvider() {
|
|
|
626
626
|
const initialUrl = /** @type {string} */ ($browser.url());
|
|
627
627
|
let appBase;
|
|
628
628
|
|
|
629
|
-
if (html5Mode.enabled) {
|
|
630
|
-
if (!baseHref && html5Mode.requireBase) {
|
|
629
|
+
if (this.html5Mode.enabled) {
|
|
630
|
+
if (!baseHref && this.html5Mode.requireBase) {
|
|
631
631
|
throw $locationMinErr(
|
|
632
632
|
"nobase",
|
|
633
633
|
"$location in HTML5 mode requires a <base> tag to be present!",
|
|
@@ -641,7 +641,11 @@ export function LocationProvider() {
|
|
|
641
641
|
}
|
|
642
642
|
const appBaseNoFile = stripFile(appBase);
|
|
643
643
|
|
|
644
|
-
$location = new LocationMode(
|
|
644
|
+
$location = new LocationMode(
|
|
645
|
+
appBase,
|
|
646
|
+
appBaseNoFile,
|
|
647
|
+
`#${this.hashPrefix}`,
|
|
648
|
+
);
|
|
645
649
|
$location.$$parseLinkUrl(initialUrl, initialUrl);
|
|
646
650
|
|
|
647
651
|
$location.$$state = $browser.state();
|
|
@@ -668,7 +672,7 @@ export function LocationProvider() {
|
|
|
668
672
|
}
|
|
669
673
|
|
|
670
674
|
$rootElement.on("click", (event) => {
|
|
671
|
-
const { rewriteLinks } = html5Mode;
|
|
675
|
+
const { rewriteLinks } = this.html5Mode;
|
|
672
676
|
// TODO(vojta): rewrite link when opening in new tab/window (in legacy browser)
|
|
673
677
|
// currently we open nice url link and redirect then
|
|
674
678
|
|
|
@@ -767,10 +771,11 @@ export function LocationProvider() {
|
|
|
767
771
|
afterLocationChange(oldUrl, oldState);
|
|
768
772
|
}
|
|
769
773
|
});
|
|
774
|
+
if ($rootScope.$$phase === ScopePhase.NONE) $rootScope.$digest();
|
|
770
775
|
});
|
|
771
776
|
|
|
772
777
|
// update browser
|
|
773
|
-
|
|
778
|
+
function browserUpdate() {
|
|
774
779
|
if (initializing || $location.$$urlUpdatedByLocation) {
|
|
775
780
|
$location.$$urlUpdatedByLocation = false;
|
|
776
781
|
|
|
@@ -818,7 +823,9 @@ export function LocationProvider() {
|
|
|
818
823
|
|
|
819
824
|
// we don't need to return anything because $evalAsync will make the digest loop dirty when
|
|
820
825
|
// there is a change
|
|
821
|
-
}
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
setTimeout(() => browserUpdate());
|
|
822
829
|
|
|
823
830
|
return $location;
|
|
824
831
|
|
|
@@ -830,6 +837,7 @@ export function LocationProvider() {
|
|
|
830
837
|
$location.$$state,
|
|
831
838
|
oldState,
|
|
832
839
|
);
|
|
840
|
+
browserUpdate();
|
|
833
841
|
}
|
|
834
842
|
},
|
|
835
843
|
];
|
|
@@ -785,7 +785,7 @@ describe("$location", () => {
|
|
|
785
785
|
// $browser,
|
|
786
786
|
// "url",
|
|
787
787
|
// ).and.callThrough();
|
|
788
|
-
// ;
|
|
788
|
+
// $rootScope.$digest();
|
|
789
789
|
// expect($browserUrl).not.toHaveBeenCalled();
|
|
790
790
|
// });
|
|
791
791
|
// });
|
|
@@ -815,7 +815,7 @@ describe("$location", () => {
|
|
|
815
815
|
// }
|
|
816
816
|
// });
|
|
817
817
|
// expect($browser.url()).toEqual("http://server/base/#!/home");
|
|
818
|
-
// ;
|
|
818
|
+
// $rootScope.$digest();
|
|
819
819
|
// expect(handlerCalled).toEqual(true);
|
|
820
820
|
// expect($browser.url()).toEqual("http://server/base/#!/");
|
|
821
821
|
// });
|
|
@@ -829,7 +829,7 @@ describe("$location", () => {
|
|
|
829
829
|
// });
|
|
830
830
|
// inject(($location, $browser, $rootScope) => {
|
|
831
831
|
// expect(() => {
|
|
832
|
-
// ;
|
|
832
|
+
// $rootScope.$digest();
|
|
833
833
|
// }).not.toThrow();
|
|
834
834
|
// });
|
|
835
835
|
// });
|
|
@@ -843,7 +843,7 @@ describe("$location", () => {
|
|
|
843
843
|
// });
|
|
844
844
|
// inject(($location, $browser, $rootScope) => {
|
|
845
845
|
// expect(() => {
|
|
846
|
-
// ;
|
|
846
|
+
// $rootScope.$digest();
|
|
847
847
|
// }).not.toThrow();
|
|
848
848
|
// });
|
|
849
849
|
// });
|
|
@@ -857,7 +857,7 @@ describe("$location", () => {
|
|
|
857
857
|
// });
|
|
858
858
|
// inject(($location, $browser, $rootScope) => {
|
|
859
859
|
// expect(() => {
|
|
860
|
-
// ;
|
|
860
|
+
// $rootScope.$digest();
|
|
861
861
|
// }).not.toThrow();
|
|
862
862
|
// });
|
|
863
863
|
// });
|
|
@@ -867,10 +867,10 @@ describe("$location", () => {
|
|
|
867
867
|
// initService({ html5Mode: true, supportHistory: true });
|
|
868
868
|
// mockUpBrowser({ initialUrl: "http://localhost:9876/", baseHref: "/" });
|
|
869
869
|
// inject(($location, $browser, $rootScope) => {
|
|
870
|
-
// ;
|
|
870
|
+
// $rootScope.$digest();
|
|
871
871
|
// $browser.url("http://localhost:9876/?q='");
|
|
872
872
|
// expect(() => {
|
|
873
|
-
// ;
|
|
873
|
+
// $rootScope.$digest();
|
|
874
874
|
// }).not.toThrow();
|
|
875
875
|
// });
|
|
876
876
|
// });
|
|
@@ -880,7 +880,7 @@ describe("$location", () => {
|
|
|
880
880
|
// initService({ html5Mode: true, supportHistory: true });
|
|
881
881
|
// mockUpBrowser({ initialUrl: "http://localhost:9876/", baseHref: "/" });
|
|
882
882
|
// inject(($window, $location, $browser, $rootScope) => {
|
|
883
|
-
// ;
|
|
883
|
+
// $rootScope.$digest();
|
|
884
884
|
// $window.location.href = "http://localhost:9876/?q='";
|
|
885
885
|
// expect(() => {
|
|
886
886
|
// JQLite($window).triggerHandler("popstate");
|
|
@@ -901,7 +901,7 @@ describe("$location", () => {
|
|
|
901
901
|
// $window,
|
|
902
902
|
// ) => {
|
|
903
903
|
// $location.url("baz");
|
|
904
|
-
// ;
|
|
904
|
+
// $rootScope.$digest();
|
|
905
905
|
|
|
906
906
|
// const originalUrl = $window.location.href;
|
|
907
907
|
|
|
@@ -931,7 +931,7 @@ describe("$location", () => {
|
|
|
931
931
|
// $window,
|
|
932
932
|
// ) => {
|
|
933
933
|
// $location.url("baz");
|
|
934
|
-
// ;
|
|
934
|
+
// $rootScope.$digest();
|
|
935
935
|
|
|
936
936
|
// $rootScope.$apply(() => {
|
|
937
937
|
// $rootScope.$evalAsync(() => {
|
|
@@ -969,7 +969,7 @@ describe("$location", () => {
|
|
|
969
969
|
|
|
970
970
|
// updatePathOnLocationChangeSuccessTo("/Home");
|
|
971
971
|
|
|
972
|
-
// ;
|
|
972
|
+
// $rootScope.$digest();
|
|
973
973
|
|
|
974
974
|
// expect($browser.url()).toEqual("http://server/app/#!/Home");
|
|
975
975
|
// expect($location.path()).toEqual("/Home");
|
|
@@ -991,7 +991,7 @@ describe("$location", () => {
|
|
|
991
991
|
|
|
992
992
|
// updatePathOnLocationChangeSuccessTo("/");
|
|
993
993
|
|
|
994
|
-
// ;
|
|
994
|
+
// $rootScope.$digest();
|
|
995
995
|
|
|
996
996
|
// expect($browser.url()).toEqual("http://server/app/#!/");
|
|
997
997
|
// expect($location.path()).toEqual("/");
|
|
@@ -1014,7 +1014,7 @@ describe("$location", () => {
|
|
|
1014
1014
|
// ).and.callThrough();
|
|
1015
1015
|
|
|
1016
1016
|
// updatePathOnLocationChangeSuccessTo("/Home");
|
|
1017
|
-
// ;
|
|
1017
|
+
// $rootScope.$digest();
|
|
1018
1018
|
|
|
1019
1019
|
// expect($browser.url()).toEqual("http://server/app/#!/Home");
|
|
1020
1020
|
// expect($location.path()).toEqual("/Home");
|
|
@@ -1037,7 +1037,7 @@ describe("$location", () => {
|
|
|
1037
1037
|
// ).and.callThrough();
|
|
1038
1038
|
|
|
1039
1039
|
// updatePathOnLocationChangeSuccessTo("/");
|
|
1040
|
-
// ;
|
|
1040
|
+
// $rootScope.$digest();
|
|
1041
1041
|
|
|
1042
1042
|
// expect($browser.url()).toEqual("http://server/app/#!/");
|
|
1043
1043
|
// expect($location.path()).toEqual("/");
|
|
@@ -1059,7 +1059,7 @@ describe("$location", () => {
|
|
|
1059
1059
|
// const $location = $injector.get("$location");
|
|
1060
1060
|
// updatePathOnLocationChangeSuccessTo("/Home");
|
|
1061
1061
|
|
|
1062
|
-
// ;
|
|
1062
|
+
// $rootScope.$digest();
|
|
1063
1063
|
|
|
1064
1064
|
// expect($browser.url()).toEqual("http://server/app/Home");
|
|
1065
1065
|
// expect($location.path()).toEqual("/Home");
|
|
@@ -1079,7 +1079,7 @@ describe("$location", () => {
|
|
|
1079
1079
|
// const $location = $injector.get("$location");
|
|
1080
1080
|
// updatePathOnLocationChangeSuccessTo("/");
|
|
1081
1081
|
|
|
1082
|
-
// ;
|
|
1082
|
+
// $rootScope.$digest();
|
|
1083
1083
|
|
|
1084
1084
|
// expect($browser.url()).toEqual("http://server/app/");
|
|
1085
1085
|
// expect($location.path()).toEqual("/");
|
|
@@ -1099,7 +1099,7 @@ describe("$location", () => {
|
|
|
1099
1099
|
// const $location = $injector.get("$location");
|
|
1100
1100
|
// updatePathOnLocationChangeSuccessTo("/Home");
|
|
1101
1101
|
|
|
1102
|
-
// ;
|
|
1102
|
+
// $rootScope.$digest();
|
|
1103
1103
|
|
|
1104
1104
|
// expect($browser.url()).toEqual("http://server/app/Home");
|
|
1105
1105
|
// expect($location.path()).toEqual("/Home");
|
|
@@ -1119,7 +1119,7 @@ describe("$location", () => {
|
|
|
1119
1119
|
// const $location = $injector.get("$location");
|
|
1120
1120
|
// updatePathOnLocationChangeSuccessTo("/");
|
|
1121
1121
|
|
|
1122
|
-
// ;
|
|
1122
|
+
// $rootScope.$digest();
|
|
1123
1123
|
|
|
1124
1124
|
// expect($browser.url()).toEqual("http://server/app/");
|
|
1125
1125
|
// expect($location.path()).toEqual("/");
|
|
@@ -1140,7 +1140,7 @@ describe("$location", () => {
|
|
|
1140
1140
|
// const $location = $injector.get("$location");
|
|
1141
1141
|
// updatePathOnLocationChangeSuccessTo("/", { q: "'" });
|
|
1142
1142
|
|
|
1143
|
-
// ;
|
|
1143
|
+
// $rootScope.$digest();
|
|
1144
1144
|
|
|
1145
1145
|
// expect($location.path()).toEqual("/");
|
|
1146
1146
|
// expect($location.search()).toEqual({ q: "'" });
|
|
@@ -1200,7 +1200,7 @@ describe("$location", () => {
|
|
|
1200
1200
|
// }
|
|
1201
1201
|
// });
|
|
1202
1202
|
|
|
1203
|
-
// ;
|
|
1203
|
+
// $rootScope.$digest();
|
|
1204
1204
|
// expect($location.absUrl()).toBe(NEW_URL);
|
|
1205
1205
|
// });
|
|
1206
1206
|
// });
|
|
@@ -1299,7 +1299,7 @@ describe("$location", () => {
|
|
|
1299
1299
|
// },
|
|
1300
1300
|
// );
|
|
1301
1301
|
|
|
1302
|
-
// ;
|
|
1302
|
+
// $rootScope.$digest();
|
|
1303
1303
|
// expect($browser.url()).toBe("http://new.com/a/b#!/changed");
|
|
1304
1304
|
// });
|
|
1305
1305
|
// });
|
|
@@ -1310,7 +1310,7 @@ describe("$location", () => {
|
|
|
1310
1310
|
// inject(($rootScope, $browser, $location) => {
|
|
1311
1311
|
// $location.hash("test");
|
|
1312
1312
|
|
|
1313
|
-
// ;
|
|
1313
|
+
// $rootScope.$digest();
|
|
1314
1314
|
// expect($browser.url()).toBe("http://new.com/a/b##test");
|
|
1315
1315
|
// });
|
|
1316
1316
|
// });
|
|
@@ -1334,7 +1334,7 @@ describe("$location", () => {
|
|
|
1334
1334
|
// mockUpBrowser({ initialUrl: "http://new.com/a/b/", baseHref: "/a/b/" });
|
|
1335
1335
|
// inject(($location, $rootScope, $window) => {
|
|
1336
1336
|
// $window.history.pushState({ b: 3 });
|
|
1337
|
-
// ;
|
|
1337
|
+
// $rootScope.$digest();
|
|
1338
1338
|
|
|
1339
1339
|
// expect($location.state()).toEqual({ b: 3 });
|
|
1340
1340
|
|
|
@@ -1343,7 +1343,7 @@ describe("$location", () => {
|
|
|
1343
1343
|
// null,
|
|
1344
1344
|
// `${$window.location.href}c?d=e#f`,
|
|
1345
1345
|
// );
|
|
1346
|
-
// ;
|
|
1346
|
+
// $rootScope.$digest();
|
|
1347
1347
|
|
|
1348
1348
|
// expect($location.path()).toBe("/c");
|
|
1349
1349
|
// expect($location.search()).toEqual({ d: "e" });
|
|
@@ -1358,10 +1358,10 @@ describe("$location", () => {
|
|
|
1358
1358
|
// mockUpBrowser({ initialUrl: "http://server/app/", baseHref: "/app/" });
|
|
1359
1359
|
// inject(($rootScope, $injector, $window) => {
|
|
1360
1360
|
// const $location = $injector.get("$location");
|
|
1361
|
-
// ; // allow $location initialization to finish
|
|
1361
|
+
// $rootScope.$digest(); // allow $location initialization to finish
|
|
1362
1362
|
|
|
1363
1363
|
// $window.history.pushState({}, null, "http://server/app/Home?q='");
|
|
1364
|
-
// ;
|
|
1364
|
+
// $rootScope.$digest();
|
|
1365
1365
|
|
|
1366
1366
|
// expect($location.absUrl()).toEqual("http://server/app/Home?q='");
|
|
1367
1367
|
// expect($location.path()).toEqual("/Home");
|
|
@@ -1375,7 +1375,7 @@ describe("$location", () => {
|
|
|
1375
1375
|
// mockUpBrowser({ initialUrl: "http://server/app/", baseHref: "/app/" });
|
|
1376
1376
|
// inject(($rootScope, $injector, $window) => {
|
|
1377
1377
|
// const $location = $injector.get("$location");
|
|
1378
|
-
// ; // allow $location initialization to finish
|
|
1378
|
+
// $rootScope.$digest(); // allow $location initialization to finish
|
|
1379
1379
|
|
|
1380
1380
|
// $window.location.href = "http://server/app/Home?q='";
|
|
1381
1381
|
// JQLite($window).triggerHandler("popstate");
|