@angular-wave/angular.ts 0.0.68 → 0.0.69
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-swap.js +1 -1
- package/src/core/animate/animate.js +5 -5
- package/src/core/compile/compile.spec.js +2 -2
- package/src/core/controller/controller.js +5 -1
- package/src/core/cookie-reader.spec.js +1 -1
- package/src/core/di/injector.js +1 -1
- package/src/core/di/injector.spec.js +35 -35
- package/src/core/di/internal-injector.js +1 -1
- package/src/core/filter/filter.spec.js +15 -15
- package/src/core/interpolate/interpolate.spec.js +29 -29
- package/src/core/interval/interval.spec.js +1 -1
- package/src/core/location/location.spec.js +1 -1
- package/src/core/parser/lexer.spec.js +1 -1
- package/src/core/parser/parse.spec.js +1 -1
- package/src/core/q/q.js +1 -0
- package/src/core/q/q.spec.js +1 -1
- package/src/core/scope/scope.js +1 -1
- package/src/core/timeout/timeout.js +5 -21
- package/src/directive/attrs/boolean.spec.js +1 -1
- package/src/directive/bind/bind.js +2 -2
- package/src/directive/class/class.js +1 -1
- package/src/directive/form/form.js +1 -18
- package/src/directive/form/form.spec.js +2 -2
- package/src/directive/include/include.js +7 -0
- package/src/directive/input/input.js +1 -1
- package/src/{exts → directive}/messages/messages.html +4 -1
- package/src/directive/messages/messages.js +346 -0
- package/src/{exts → directive}/messages/messages.spec.js +7 -11
- package/src/{exts → directive}/messages/messages.test.js +1 -1
- package/src/directive/model-options/model-options.spec.js +1 -1
- package/src/directive/switch/switch.spec.js +1 -1
- package/src/exts/aria/aria.spec.js +1 -1
- package/src/filters/filter.js +2 -3
- package/src/filters/filter.spec.js +1 -1
- package/src/filters/filters.spec.js +1 -1
- package/src/filters/limit-to.spec.js +2 -2
- package/src/loader.js +1 -1
- package/src/loader.spec.js +1 -1
- package/src/public.js +12 -2
- package/src/router/common/glob.spec.js +1 -1
- package/src/router/params/param-factory.js +1 -1
- package/src/router/state/state-builder.spec.js +1 -1
- package/src/router/template-factory.js +6 -4
- package/src/router/view/view.spec.js +8 -11
- package/src/router/view-scroll.js +6 -1
- package/src/services/anchor-scroll.html +83 -0
- package/src/services/anchor-scroll.js +23 -6
- package/src/services/browser.js +1 -1
- package/src/services/http/http.spec.js +40 -40
- package/src/shared/jqlite/jqlite.js +3 -3
- package/src/shared/jqlite/jqlite.spec.js +4 -4
- package/src/shared/utils.js +1 -1
- package/types/core/q/q.d.ts +5 -0
- package/types/core/scope/scope.d.ts +1 -1
- package/types/core/timeout/timeout.d.ts +3 -7
- package/types/directive/form/form.d.ts +3 -20
- package/types/directive/include/include.d.ts +1 -1
- package/types/router/params/param-factory.d.ts +1 -1
- package/types/router/template-factory.d.ts +4 -4
- package/types/router/view-scroll.d.ts +1 -1
- package/types/services/anchor-scroll.d.ts +16 -1
- package/types/services/browser.d.ts +2 -2
- package/src/exts/messages/messages.js +0 -361
- package/types/exts/messages/messages.d.ts +0 -1
- /package/src/{exts → directive}/messages/messages.md +0 -0
package/src/loader.spec.js
CHANGED
package/src/public.js
CHANGED
|
@@ -90,7 +90,13 @@ import { TemplateRequestProvider } from "./services/template-request";
|
|
|
90
90
|
import { $TimeoutProvider } from "./core/timeout/timeout";
|
|
91
91
|
import { SanitizeUriProvider } from "./core/sanitize/sanitize-uri";
|
|
92
92
|
import { initAnimateModule } from "./animations/module";
|
|
93
|
-
import {
|
|
93
|
+
import {
|
|
94
|
+
ngMessageDefaultDirective,
|
|
95
|
+
ngMessageDirective,
|
|
96
|
+
ngMessageExpDirective,
|
|
97
|
+
ngMessagesDirective,
|
|
98
|
+
ngMessagesIncludeDirective,
|
|
99
|
+
} from "./directive/messages/messages";
|
|
94
100
|
import { initAriaModule } from "./exts/aria/aria";
|
|
95
101
|
import { initRouter } from "./router/index";
|
|
96
102
|
|
|
@@ -139,6 +145,11 @@ export function publishExternalAPI(angular) {
|
|
|
139
145
|
ngIf: ngIfDirective,
|
|
140
146
|
ngInclude: ngIncludeDirective,
|
|
141
147
|
ngInit: ngInitDirective,
|
|
148
|
+
ngMessages: ngMessagesDirective,
|
|
149
|
+
ngMessage: ngMessageDirective,
|
|
150
|
+
ngMessageExp: ngMessageExpDirective,
|
|
151
|
+
ngMessagesInclude: ngMessagesIncludeDirective,
|
|
152
|
+
ngMessageDefault: ngMessageDefaultDirective,
|
|
142
153
|
ngNonBindable: ngNonBindableDirective,
|
|
143
154
|
ngRef: ngRefDirective,
|
|
144
155
|
ngRepeat: ngRepeatDirective,
|
|
@@ -207,7 +218,6 @@ export function publishExternalAPI(angular) {
|
|
|
207
218
|
.info({ version: VERSION });
|
|
208
219
|
|
|
209
220
|
initAnimateModule(angular);
|
|
210
|
-
initMessageModule(angular);
|
|
211
221
|
initAriaModule(angular);
|
|
212
222
|
initRouter(angular);
|
|
213
223
|
return ng;
|
|
@@ -111,7 +111,9 @@ export class TemplateFactory {
|
|
|
111
111
|
* string.
|
|
112
112
|
*/
|
|
113
113
|
fromString(template, params) {
|
|
114
|
-
return isFunction(template)
|
|
114
|
+
return isFunction(template)
|
|
115
|
+
? /** @type {Function} */ (template)(params)
|
|
116
|
+
: template;
|
|
115
117
|
}
|
|
116
118
|
/**
|
|
117
119
|
* Loads a template from the a URL via `$http` and `$templateCache`.
|
|
@@ -123,7 +125,7 @@ export class TemplateFactory {
|
|
|
123
125
|
* for that string.
|
|
124
126
|
*/
|
|
125
127
|
fromUrl(url, params) {
|
|
126
|
-
if (isFunction(url)) url = url(params);
|
|
128
|
+
if (isFunction(url)) url = /** @type {Function} */ (url)(params);
|
|
127
129
|
if (url == null) return null;
|
|
128
130
|
if (this._useHttp) {
|
|
129
131
|
return this.$http
|
|
@@ -141,7 +143,7 @@ export class TemplateFactory {
|
|
|
141
143
|
* Creates a template by invoking an injectable provider function.
|
|
142
144
|
*
|
|
143
145
|
* @param {import('../types').Injectable<any>} provider Function to invoke via `locals`
|
|
144
|
-
* @param {Function}
|
|
146
|
+
* @param {Function} params a function used to invoke the template provider
|
|
145
147
|
* @param {import("./resolve/resolve-context").ResolveContext} context
|
|
146
148
|
* @return {string|Promise.<string>} The template html as a string, or a promise
|
|
147
149
|
* for that string.
|
|
@@ -156,7 +158,7 @@ export class TemplateFactory {
|
|
|
156
158
|
* Creates a component's template by invoking an injectable provider function.
|
|
157
159
|
*
|
|
158
160
|
* @param {import('../types').Injectable<any>} provider Function to invoke via `locals`
|
|
159
|
-
* @param {Function}
|
|
161
|
+
* @param {Function} params a function used to invoke the template provider
|
|
160
162
|
* @return {string} The template html as a string: "<component-name input1='::$resolve.foo'></component-name>".
|
|
161
163
|
*/
|
|
162
164
|
fromComponentProvider(provider, params, context) {
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import { dealoc
|
|
1
|
+
import { dealoc } from "../../shared/jqlite/jqlite";
|
|
2
2
|
import { Angular } from "../../loader";
|
|
3
3
|
import { curry } from "../../shared/hof";
|
|
4
|
-
import { StateMatcher } from "
|
|
5
|
-
import { StateBuilder } from "
|
|
6
|
-
import { StateObject } from "
|
|
7
|
-
import { ViewService } from "
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} from "../../router/state/views";
|
|
12
|
-
import { PathNode } from "../../router/path/path-node";
|
|
13
|
-
import { PathUtils } from "../../router/path/path-utils";
|
|
4
|
+
import { StateMatcher } from "../state/state-matcher";
|
|
5
|
+
import { StateBuilder } from "../state/state-builder";
|
|
6
|
+
import { StateObject } from "../state/state-object";
|
|
7
|
+
import { ViewService } from "./view.js";
|
|
8
|
+
import { ng1ViewsBuilder, getNg1ViewConfigFactory } from "../state/views.js";
|
|
9
|
+
import { PathNode } from "../path/path-node";
|
|
10
|
+
import { PathUtils } from "../path/path-utils";
|
|
14
11
|
import { tail } from "../../shared/common";
|
|
15
12
|
import { wait } from "../../shared/test-utils";
|
|
16
13
|
|
|
@@ -6,7 +6,12 @@ export function $ViewScrollProvider() {
|
|
|
6
6
|
this.$get = [
|
|
7
7
|
"$anchorScroll",
|
|
8
8
|
"$timeout",
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* @param {import('../services/anchor-scroll').AnchorScrollObject} $anchorScroll
|
|
11
|
+
* @param {*} $timeout
|
|
12
|
+
* @returns {import('../services/anchor-scroll').AnchorScrollObject|Function}
|
|
13
|
+
*/
|
|
14
|
+
($anchorScroll, $timeout) => {
|
|
10
15
|
if (useAnchorScroll) {
|
|
11
16
|
return $anchorScroll;
|
|
12
17
|
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<title>AngularTS Test Runner</title>
|
|
6
|
+
|
|
7
|
+
<link rel="shortcut icon" type="image/png" href="/images/favicon.ico" />
|
|
8
|
+
|
|
9
|
+
<!--
|
|
10
|
+
<script src="https://cdn.jsdelivr.net/npm/angular@1.8.3/angular.js"></script>
|
|
11
|
+
<script src="https://cdn.jsdelivr.net/npm/angular-animate@1.8.3/angular-animate.js"></script>
|
|
12
|
+
<script>window.angular.module("test", ["ngAnimate"])</script> -->
|
|
13
|
+
|
|
14
|
+
<script type="module" src="/src/index.js"></script>
|
|
15
|
+
<script>
|
|
16
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
17
|
+
window.angular
|
|
18
|
+
.module("test", [])
|
|
19
|
+
.run([
|
|
20
|
+
"$anchorScroll",
|
|
21
|
+
function ($anchorScroll) {
|
|
22
|
+
$anchorScroll.yOffset = 100; // always scroll by 50 extra pixels
|
|
23
|
+
},
|
|
24
|
+
])
|
|
25
|
+
.controller("headerCtrl", [
|
|
26
|
+
"$anchorScroll",
|
|
27
|
+
"$location",
|
|
28
|
+
"$scope",
|
|
29
|
+
function ($anchorScroll, $location, $scope) {
|
|
30
|
+
$scope.gotoAnchor = function (x) {
|
|
31
|
+
window.$locationTest = $location;
|
|
32
|
+
var newHash = "anchor" + x;
|
|
33
|
+
if ($location.hash() !== newHash) {
|
|
34
|
+
// set the $location.hash to `newHash` and
|
|
35
|
+
// $anchorScroll will automatically scroll to it
|
|
36
|
+
$location.hash("anchor" + x);
|
|
37
|
+
} else {
|
|
38
|
+
// call $anchorScroll() explicitly,
|
|
39
|
+
// since $location.hash hasn't changed
|
|
40
|
+
$anchorScroll();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
]);
|
|
45
|
+
});
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<style>
|
|
49
|
+
body {
|
|
50
|
+
padding-top: 50px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.anchor {
|
|
54
|
+
border: 2px dashed DarkOrchid;
|
|
55
|
+
padding: 10px 10px 200px 10px;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.fixed-header {
|
|
59
|
+
background-color: rgba(0, 0, 0, 0.2);
|
|
60
|
+
height: 50px;
|
|
61
|
+
position: fixed;
|
|
62
|
+
top: 0;
|
|
63
|
+
left: 0;
|
|
64
|
+
right: 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.fixed-header > a {
|
|
68
|
+
display: inline-block;
|
|
69
|
+
margin: 5px 15px;
|
|
70
|
+
}
|
|
71
|
+
</style>
|
|
72
|
+
</head>
|
|
73
|
+
<body ng-app="test">
|
|
74
|
+
<div class="fixed-header" ng-controller="headerCtrl">
|
|
75
|
+
<a ng-click="gotoAnchor(x)" ng-repeat="x in [1,2,3,4,5]">
|
|
76
|
+
Go to anchor {{x}}
|
|
77
|
+
</a>
|
|
78
|
+
</div>
|
|
79
|
+
<div id="anchor{{x}}" class="anchor" ng-repeat="x in [1,2,3,4,5]">
|
|
80
|
+
Anchor {{x}} of 5
|
|
81
|
+
</div>
|
|
82
|
+
</body>
|
|
83
|
+
</html>
|
|
@@ -6,6 +6,19 @@ import {
|
|
|
6
6
|
getNodeName,
|
|
7
7
|
} from "../shared/utils";
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {Object} AnchorScrollObject
|
|
11
|
+
* @property {number|function|import("../shared/jqlite/jqlite").JQLite} yOffset
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {(string) => void} AnchorScrollFunction
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {AnchorScrollFunction | AnchorScrollObject} AnchorScrollService
|
|
20
|
+
*/
|
|
21
|
+
|
|
9
22
|
export function AnchorScrollProvider() {
|
|
10
23
|
let autoScrollingEnabled = true;
|
|
11
24
|
|
|
@@ -38,10 +51,11 @@ export function AnchorScrollProvider() {
|
|
|
38
51
|
}
|
|
39
52
|
|
|
40
53
|
function getYOffset() {
|
|
41
|
-
|
|
54
|
+
// Figure out a better way to configure this other than bolting on a property onto a function
|
|
55
|
+
let offset = /** @type {AnchorScrollObject} */ (scroll).yOffset;
|
|
42
56
|
|
|
43
57
|
if (isFunction(offset)) {
|
|
44
|
-
offset = offset();
|
|
58
|
+
offset = /** @type {Function} */ (offset)();
|
|
45
59
|
} else if (isElement(offset)) {
|
|
46
60
|
const elem = offset[0];
|
|
47
61
|
const style = window.getComputedStyle(elem);
|
|
@@ -78,14 +92,15 @@ export function AnchorScrollProvider() {
|
|
|
78
92
|
// the top of the element and the offset, which is enough to align the top of `elem` at the
|
|
79
93
|
// desired position.
|
|
80
94
|
const elemTop = elem.getBoundingClientRect().top;
|
|
81
|
-
window.scrollBy(0, elemTop - offset);
|
|
95
|
+
window.scrollBy(0, elemTop - /** @type {number} */ (offset));
|
|
82
96
|
}
|
|
83
97
|
} else {
|
|
84
98
|
window.scrollTo(0, 0);
|
|
85
99
|
}
|
|
86
100
|
}
|
|
87
101
|
|
|
88
|
-
|
|
102
|
+
/** @type {AnchorScrollService} */
|
|
103
|
+
const scroll = function (hash) {
|
|
89
104
|
// Allow numeric hashes
|
|
90
105
|
hash = isString(hash)
|
|
91
106
|
? hash
|
|
@@ -95,7 +110,9 @@ export function AnchorScrollProvider() {
|
|
|
95
110
|
let elm;
|
|
96
111
|
|
|
97
112
|
// empty hash, scroll to the top of the page
|
|
98
|
-
if (!hash)
|
|
113
|
+
if (!hash) {
|
|
114
|
+
scrollTo(null);
|
|
115
|
+
}
|
|
99
116
|
// element with given id
|
|
100
117
|
else if ((elm = document.getElementById(hash))) scrollTo(elm);
|
|
101
118
|
// first anchor with given name :-D
|
|
@@ -103,7 +120,7 @@ export function AnchorScrollProvider() {
|
|
|
103
120
|
scrollTo(elm);
|
|
104
121
|
// no element and hash === 'top', scroll to the top of the page
|
|
105
122
|
else if (hash === "top") scrollTo(null);
|
|
106
|
-
}
|
|
123
|
+
};
|
|
107
124
|
|
|
108
125
|
// does not scroll when user clicks on anchor link that is currently on
|
|
109
126
|
// (no url change, no $location.hash() change), browser native does scroll
|
package/src/services/browser.js
CHANGED
|
@@ -242,7 +242,7 @@ export function Browser(taskTracker) {
|
|
|
242
242
|
* @param {function():any} fn A function, who's execution should be deferred.
|
|
243
243
|
* @param {number=} [delay=0] Number of milliseconds to defer the function execution.
|
|
244
244
|
* @param {string=} [taskType=DEFAULT_TASK_TYPE] The type of task that is deferred.
|
|
245
|
-
* @returns {
|
|
245
|
+
* @returns {number} DeferId that can be used to cancel the task via `$browser.cancel()`.
|
|
246
246
|
*
|
|
247
247
|
* @description
|
|
248
248
|
* Executes a fn asynchronously via `setTimeout(fn, delay)`.
|
|
@@ -27,7 +27,7 @@ describe("$http", function () {
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
it("returns a Promise", function () {
|
|
30
|
-
|
|
30
|
+
const result = $http({ url: "test" });
|
|
31
31
|
expect(result).toBeDefined();
|
|
32
32
|
expect(result.then).toBeDefined();
|
|
33
33
|
});
|
|
@@ -197,11 +197,11 @@ describe("$http", function () {
|
|
|
197
197
|
});
|
|
198
198
|
|
|
199
199
|
it("supports functions as header values", async function () {
|
|
200
|
-
|
|
200
|
+
const contentTypeSpy = jasmine
|
|
201
201
|
.createSpy()
|
|
202
202
|
.and.returnValue("text/plain;charset=utf-8");
|
|
203
203
|
$http.defaults.headers.post["Content-Type"] = contentTypeSpy;
|
|
204
|
-
|
|
204
|
+
const request = {
|
|
205
205
|
method: "POST",
|
|
206
206
|
url: "/mock/hello",
|
|
207
207
|
data: 42,
|
|
@@ -216,9 +216,9 @@ describe("$http", function () {
|
|
|
216
216
|
});
|
|
217
217
|
|
|
218
218
|
it("ignores header function value when null/undefined", async function () {
|
|
219
|
-
|
|
219
|
+
const cacheControlSpy = jasmine.createSpy().and.returnValue(null);
|
|
220
220
|
$http.defaults.headers.post["Cache-Control"] = cacheControlSpy;
|
|
221
|
-
|
|
221
|
+
const request = {
|
|
222
222
|
method: "POST",
|
|
223
223
|
url: "/mock/hello",
|
|
224
224
|
data: 42,
|
|
@@ -284,7 +284,7 @@ describe("$http", function () {
|
|
|
284
284
|
});
|
|
285
285
|
|
|
286
286
|
it("allows transforming requests with functions", async function () {
|
|
287
|
-
|
|
287
|
+
let transformedData;
|
|
288
288
|
await $http({
|
|
289
289
|
method: "POST",
|
|
290
290
|
url: "/mock/hello",
|
|
@@ -300,7 +300,7 @@ describe("$http", function () {
|
|
|
300
300
|
});
|
|
301
301
|
|
|
302
302
|
it("allows multiple request transform functions", async function () {
|
|
303
|
-
|
|
303
|
+
let transformedData;
|
|
304
304
|
await $http({
|
|
305
305
|
method: "POST",
|
|
306
306
|
url: "/mock/hello",
|
|
@@ -320,7 +320,7 @@ describe("$http", function () {
|
|
|
320
320
|
});
|
|
321
321
|
|
|
322
322
|
it("allows settings transforms in defaults", async function () {
|
|
323
|
-
|
|
323
|
+
let transformedData;
|
|
324
324
|
$http.defaults.transformRequest = [
|
|
325
325
|
function (data) {
|
|
326
326
|
transformedData = "*" + data + "*";
|
|
@@ -336,7 +336,7 @@ describe("$http", function () {
|
|
|
336
336
|
});
|
|
337
337
|
|
|
338
338
|
it("passes request headers getter to transforms", async function () {
|
|
339
|
-
|
|
339
|
+
let transformedData;
|
|
340
340
|
$http.defaults.transformRequest = [
|
|
341
341
|
function (data, headers) {
|
|
342
342
|
if (headers("Content-Type") === "text/emphasized") {
|
|
@@ -417,7 +417,7 @@ describe("$http", function () {
|
|
|
417
417
|
});
|
|
418
418
|
|
|
419
419
|
it("passes HTTP status to response transformers", async function () {
|
|
420
|
-
|
|
420
|
+
let response;
|
|
421
421
|
await $http({
|
|
422
422
|
url: "/mock/401",
|
|
423
423
|
transformResponse: function (data, headers, status) {
|
|
@@ -461,16 +461,16 @@ describe("$http", function () {
|
|
|
461
461
|
});
|
|
462
462
|
|
|
463
463
|
it("does not serialize blobs for requests", async function () {
|
|
464
|
-
|
|
464
|
+
let blob;
|
|
465
465
|
if (window.Blob) {
|
|
466
466
|
blob = new Blob(["hello"]);
|
|
467
467
|
} else {
|
|
468
|
-
|
|
468
|
+
const BlobBuilder =
|
|
469
469
|
window.BlobBuilder ||
|
|
470
470
|
window.WebKitBlobBuilder ||
|
|
471
471
|
window.MozBlobBuilder ||
|
|
472
472
|
window.MSBlobBuilder;
|
|
473
|
-
|
|
473
|
+
const bb = new BlobBuilder();
|
|
474
474
|
bb.append("hello");
|
|
475
475
|
blob = bb.getBlob("text/plain");
|
|
476
476
|
}
|
|
@@ -489,7 +489,7 @@ describe("$http", function () {
|
|
|
489
489
|
});
|
|
490
490
|
|
|
491
491
|
it("does not serialize form data for requests", async function () {
|
|
492
|
-
|
|
492
|
+
const formData = new FormData();
|
|
493
493
|
formData.append("aField", "aValue");
|
|
494
494
|
await $http({
|
|
495
495
|
method: "POST",
|
|
@@ -548,7 +548,7 @@ describe("$http", function () {
|
|
|
548
548
|
});
|
|
549
549
|
|
|
550
550
|
it("does not choke on response resembling JSON but not valid", async function () {
|
|
551
|
-
|
|
551
|
+
let response;
|
|
552
552
|
await $http({
|
|
553
553
|
method: "POST",
|
|
554
554
|
url: "/mock/invalidarray",
|
|
@@ -561,7 +561,7 @@ describe("$http", function () {
|
|
|
561
561
|
});
|
|
562
562
|
|
|
563
563
|
it("does not try to parse interpolation expr as JSON", async function () {
|
|
564
|
-
|
|
564
|
+
let response;
|
|
565
565
|
await $http({
|
|
566
566
|
method: "GET",
|
|
567
567
|
url: "/mock/interpolation",
|
|
@@ -716,7 +716,7 @@ describe("$http", function () {
|
|
|
716
716
|
});
|
|
717
717
|
|
|
718
718
|
it("allows substituting param serializer through DI", async function () {
|
|
719
|
-
|
|
719
|
+
const injector = createInjector([
|
|
720
720
|
"ng",
|
|
721
721
|
function ($provide) {
|
|
722
722
|
$provide.factory("mySpecialSerializer", function () {
|
|
@@ -752,9 +752,9 @@ describe("$http", function () {
|
|
|
752
752
|
});
|
|
753
753
|
|
|
754
754
|
it("makes default param serializer available through DI", async function () {
|
|
755
|
-
|
|
755
|
+
const injector = createInjector(["ng"]);
|
|
756
756
|
injector.invoke(function ($httpParamSerializer) {
|
|
757
|
-
|
|
757
|
+
const result = $httpParamSerializer({ a: 42, b: 43 });
|
|
758
758
|
expect(result).toEqual("a=42&b=43");
|
|
759
759
|
});
|
|
760
760
|
});
|
|
@@ -859,8 +859,8 @@ describe("$http", function () {
|
|
|
859
859
|
});
|
|
860
860
|
|
|
861
861
|
it("allows attaching interceptor factories", async function () {
|
|
862
|
-
|
|
863
|
-
|
|
862
|
+
const interceptorFactorySpy = jasmine.createSpy();
|
|
863
|
+
const injector = createInjector([
|
|
864
864
|
"ng",
|
|
865
865
|
function ($httpProvider) {
|
|
866
866
|
$httpProvider.interceptors.push(interceptorFactorySpy);
|
|
@@ -872,22 +872,22 @@ describe("$http", function () {
|
|
|
872
872
|
});
|
|
873
873
|
|
|
874
874
|
it("uses DI to instantiate interceptors", async function () {
|
|
875
|
-
|
|
876
|
-
|
|
875
|
+
const interceptorFactorySpy = jasmine.createSpy();
|
|
876
|
+
const injector = createInjector([
|
|
877
877
|
"ng",
|
|
878
878
|
function ($httpProvider) {
|
|
879
879
|
$httpProvider.interceptors.push(["$rootScope", interceptorFactorySpy]);
|
|
880
880
|
},
|
|
881
881
|
]);
|
|
882
882
|
$http = injector.get("$http");
|
|
883
|
-
|
|
883
|
+
const $rootScope = injector.get("$rootScope");
|
|
884
884
|
|
|
885
885
|
expect(interceptorFactorySpy).toHaveBeenCalledWith($rootScope);
|
|
886
886
|
});
|
|
887
887
|
|
|
888
888
|
it("allows referencing existing interceptor factories", async function () {
|
|
889
|
-
|
|
890
|
-
|
|
889
|
+
const interceptorFactorySpy = jasmine.createSpy().and.returnValue({});
|
|
890
|
+
const injector = createInjector([
|
|
891
891
|
"ng",
|
|
892
892
|
function ($provide, $httpProvider) {
|
|
893
893
|
$provide.factory("myInterceptor", interceptorFactorySpy);
|
|
@@ -900,7 +900,7 @@ describe("$http", function () {
|
|
|
900
900
|
});
|
|
901
901
|
|
|
902
902
|
it("allows intercepting requests", async function () {
|
|
903
|
-
|
|
903
|
+
const injector = createInjector([
|
|
904
904
|
"ng",
|
|
905
905
|
function ($httpProvider) {
|
|
906
906
|
$httpProvider.interceptors.push(function () {
|
|
@@ -930,7 +930,7 @@ describe("$http", function () {
|
|
|
930
930
|
});
|
|
931
931
|
|
|
932
932
|
it("allows returning promises from request intercepts", async function () {
|
|
933
|
-
|
|
933
|
+
const injector = createInjector([
|
|
934
934
|
"ng",
|
|
935
935
|
function ($httpProvider) {
|
|
936
936
|
$httpProvider.interceptors.push(function ($q) {
|
|
@@ -959,7 +959,7 @@ describe("$http", function () {
|
|
|
959
959
|
});
|
|
960
960
|
|
|
961
961
|
it("allows intercepting responses", async function () {
|
|
962
|
-
|
|
962
|
+
const injector = createInjector([
|
|
963
963
|
"ng",
|
|
964
964
|
function ($httpProvider) {
|
|
965
965
|
$httpProvider.interceptors.push(() => ({
|
|
@@ -973,7 +973,7 @@ describe("$http", function () {
|
|
|
973
973
|
$http = injector.get("$http");
|
|
974
974
|
$rootScope = injector.get("$rootScope");
|
|
975
975
|
|
|
976
|
-
|
|
976
|
+
let response;
|
|
977
977
|
await $http.get("/mock/hello").then(function (r) {
|
|
978
978
|
response = r;
|
|
979
979
|
});
|
|
@@ -983,8 +983,8 @@ describe("$http", function () {
|
|
|
983
983
|
});
|
|
984
984
|
|
|
985
985
|
it("allows intercepting request errors", async function () {
|
|
986
|
-
|
|
987
|
-
|
|
986
|
+
const requestErrorSpy = jasmine.createSpy();
|
|
987
|
+
const injector = createInjector([
|
|
988
988
|
"ng",
|
|
989
989
|
function ($httpProvider) {
|
|
990
990
|
$httpProvider.interceptors.push(() => ({
|
|
@@ -1012,8 +1012,8 @@ describe("$http", function () {
|
|
|
1012
1012
|
});
|
|
1013
1013
|
|
|
1014
1014
|
it("allows intercepting response errors", async function () {
|
|
1015
|
-
|
|
1016
|
-
|
|
1015
|
+
const responseErrorSpy = jasmine.createSpy();
|
|
1016
|
+
const injector = createInjector([
|
|
1017
1017
|
"ng",
|
|
1018
1018
|
function ($httpProvider) {
|
|
1019
1019
|
$httpProvider.interceptors.push(() => ({
|
|
@@ -1037,7 +1037,7 @@ describe("$http", function () {
|
|
|
1037
1037
|
});
|
|
1038
1038
|
|
|
1039
1039
|
it("allows attaching success handlers", async function () {
|
|
1040
|
-
|
|
1040
|
+
let data, status, config;
|
|
1041
1041
|
await $http.get("/mock/hello").then(function (res) {
|
|
1042
1042
|
data = res.data;
|
|
1043
1043
|
status = res.status;
|
|
@@ -1051,7 +1051,7 @@ describe("$http", function () {
|
|
|
1051
1051
|
});
|
|
1052
1052
|
|
|
1053
1053
|
it("allows attaching error handlers", async function () {
|
|
1054
|
-
|
|
1054
|
+
let res;
|
|
1055
1055
|
await $http.get("/mock/401").then(
|
|
1056
1056
|
() => {},
|
|
1057
1057
|
function (r) {
|
|
@@ -1184,7 +1184,7 @@ describe("$http", function () {
|
|
|
1184
1184
|
});
|
|
1185
1185
|
|
|
1186
1186
|
it("allows aborting a request with a Promise", async function () {
|
|
1187
|
-
|
|
1187
|
+
const timeout = $q.defer();
|
|
1188
1188
|
$http
|
|
1189
1189
|
.get("/mock/never", {
|
|
1190
1190
|
timeout: timeout.promise,
|
|
@@ -1242,7 +1242,7 @@ describe("$http", function () {
|
|
|
1242
1242
|
|
|
1243
1243
|
describe("useApplyAsync", function () {
|
|
1244
1244
|
beforeEach(function () {
|
|
1245
|
-
|
|
1245
|
+
const injector = createInjector([
|
|
1246
1246
|
"ng",
|
|
1247
1247
|
function ($httpProvider) {
|
|
1248
1248
|
$httpProvider.useApplyAsync(true);
|
|
@@ -1253,7 +1253,7 @@ describe("$http", function () {
|
|
|
1253
1253
|
});
|
|
1254
1254
|
|
|
1255
1255
|
it("does not resolve promise immediately when enabled", async function () {
|
|
1256
|
-
|
|
1256
|
+
const resolvedSpy = jasmine.createSpy();
|
|
1257
1257
|
$http.get("/mock/hello").then(resolvedSpy);
|
|
1258
1258
|
$rootScope.$apply();
|
|
1259
1259
|
|
|
@@ -1261,7 +1261,7 @@ describe("$http", function () {
|
|
|
1261
1261
|
});
|
|
1262
1262
|
|
|
1263
1263
|
it("resolves promise later when enabled", async function () {
|
|
1264
|
-
|
|
1264
|
+
const resolvedSpy = jasmine.createSpy();
|
|
1265
1265
|
await $http.get("/mock/hello").then(resolvedSpy);
|
|
1266
1266
|
$rootScope.$apply();
|
|
1267
1267
|
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
lowercase,
|
|
13
13
|
getNodeName,
|
|
14
14
|
shallowCopy,
|
|
15
|
-
} from "
|
|
15
|
+
} from "../utils";
|
|
16
16
|
import { CACHE, EXPANDO } from "../../core/cache/cache";
|
|
17
17
|
|
|
18
18
|
/** @type {number} */
|
|
@@ -1117,7 +1117,7 @@ function specialMouseHandlerWrapper(target, event, handler) {
|
|
|
1117
1117
|
export function startingTag(elementStr) {
|
|
1118
1118
|
const clone = JQLite(elementStr)[0].cloneNode(true);
|
|
1119
1119
|
const element = JQLite(clone).empty();
|
|
1120
|
-
|
|
1120
|
+
const elemHtml = JQLite("<div></div>").append(element[0]).html();
|
|
1121
1121
|
try {
|
|
1122
1122
|
return element[0].nodeType === Node.TEXT_NODE
|
|
1123
1123
|
? lowercase(elemHtml)
|
|
@@ -1170,7 +1170,7 @@ export function getBooleanAttrName(element, name) {
|
|
|
1170
1170
|
*/
|
|
1171
1171
|
export function cleanElementData(nodes) {
|
|
1172
1172
|
for (let i = 0, ii = nodes.length; i < ii; i++) {
|
|
1173
|
-
|
|
1173
|
+
const events = (CACHE.get(nodes[i][EXPANDO]) || {}).events;
|
|
1174
1174
|
if (events && events.$destroy) {
|
|
1175
1175
|
JQLite(nodes[i]).triggerHandler("$destroy");
|
|
1176
1176
|
}
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
} from "./jqlite";
|
|
9
9
|
import { Angular } from "../../loader";
|
|
10
10
|
import { createInjector } from "../../core/di/injector";
|
|
11
|
-
import { equals, forEach } from "
|
|
12
|
-
import { browserTrigger } from "
|
|
11
|
+
import { equals, forEach } from "../utils";
|
|
12
|
+
import { browserTrigger } from "../test-utils";
|
|
13
13
|
import { CACHE, EXPANDO } from "../../core/cache/cache";
|
|
14
14
|
|
|
15
15
|
describe("jqLite", () => {
|
|
@@ -592,8 +592,8 @@ describe("jqLite", () => {
|
|
|
592
592
|
});
|
|
593
593
|
|
|
594
594
|
it("should emit $destroy event if element removed via remove()", function () {
|
|
595
|
-
|
|
596
|
-
|
|
595
|
+
let log = "";
|
|
596
|
+
const element = JQLite(a);
|
|
597
597
|
element.on("$destroy", function () {
|
|
598
598
|
log += "destroy;";
|
|
599
599
|
});
|
package/src/shared/utils.js
CHANGED