@angular-wave/angular.ts 0.0.68 → 0.0.70
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.js +0 -1
- package/src/core/compile/compile.spec.js +4 -4
- 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 -2
- package/src/core/timeout/timeout.js +5 -21
- package/src/{exts → directive}/aria/aria.html +1 -1
- package/src/directive/aria/aria.js +382 -0
- package/src/{exts → directive}/aria/aria.spec.js +13 -13
- package/src/{exts → directive}/aria/aria.test.js +1 -1
- 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 +339 -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/filters/filter.js +2 -6
- package/src/filters/filter.spec.js +1 -1
- package/src/filters/filters.spec.js +1 -1
- package/src/filters/limit-to.js +0 -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 +39 -5
- 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 -3
- package/types/core/q/q.d.ts +5 -0
- package/types/core/scope/scope.d.ts +2 -3
- package/types/core/timeout/timeout.d.ts +3 -7
- package/types/directive/aria/aria.d.ts +94 -0
- 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/types/shared/utils.d.ts +0 -2
- package/src/exts/aria/aria.js +0 -415
- package/src/exts/messages/messages.js +0 -361
- package/types/exts/aria/aria.d.ts +0 -1
- package/types/exts/messages/messages.d.ts +0 -1
- /package/src/{exts → directive}/aria/aria.md +0 -0
- /package/src/{exts → directive}/messages/messages.md +0 -0
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@angular-wave/angular.ts",
|
|
3
3
|
"description": "A modern, optimized and typesafe version of AngularJS",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.70",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/angular-ts.esm.js",
|
|
8
8
|
"browser": "dist/angular-ts.umd.js",
|
|
@@ -136,13 +136,13 @@ export function CoreAnimateQueueProvider() {
|
|
|
136
136
|
|
|
137
137
|
function handleCSSClassChanges() {
|
|
138
138
|
forEach(postDigestElements, function (element) {
|
|
139
|
-
|
|
139
|
+
const data = postDigestQueue.get(element);
|
|
140
140
|
if (data) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
const existing = splitClasses(element.attr("class"));
|
|
142
|
+
let toAdd = "";
|
|
143
|
+
let toRemove = "";
|
|
144
144
|
forEach(data, function (status, className) {
|
|
145
|
-
|
|
145
|
+
const hasClass = !!existing[className];
|
|
146
146
|
if (status !== hasClass) {
|
|
147
147
|
if (status) {
|
|
148
148
|
toAdd += (toAdd.length ? " " : "") + className;
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
getNodeName,
|
|
10
10
|
extend,
|
|
11
11
|
} from "../../shared/utils";
|
|
12
|
-
import { countChildScopes, countWatchers } from "
|
|
13
|
-
import { CACHE, EXPANDO } from "
|
|
12
|
+
import { countChildScopes, countWatchers } from "../scope/scope";
|
|
13
|
+
import { CACHE, EXPANDO } from "../cache/cache";
|
|
14
14
|
import { wait } from "../../shared/test-utils";
|
|
15
15
|
|
|
16
16
|
function isUnknownElement(el) {
|
|
@@ -7753,7 +7753,7 @@ describe("$compile", () => {
|
|
|
7753
7753
|
expect(
|
|
7754
7754
|
element[0].outerHTML.replace(' selected="selected"', ""),
|
|
7755
7755
|
).toEqual(
|
|
7756
|
-
'<select ng-model="x" class="ng-pristine ng-untouched ng-valid ng-empty">' +
|
|
7756
|
+
'<select ng-model="x" class="ng-pristine ng-untouched ng-valid ng-empty" aria-invalid="false">' +
|
|
7757
7757
|
'<option value="">Greet !</option>' +
|
|
7758
7758
|
"</select>",
|
|
7759
7759
|
);
|
|
@@ -7762,7 +7762,7 @@ describe("$compile", () => {
|
|
|
7762
7762
|
expect(
|
|
7763
7763
|
element[0].outerHTML.replace(' selected="selected"', ""),
|
|
7764
7764
|
).toEqual(
|
|
7765
|
-
'<select ng-model="x" class="ng-pristine ng-untouched ng-valid ng-empty">' +
|
|
7765
|
+
'<select ng-model="x" class="ng-pristine ng-untouched ng-valid ng-empty" aria-invalid="false">' +
|
|
7766
7766
|
'<option value="">Greet Misko!</option>' +
|
|
7767
7767
|
"</select>",
|
|
7768
7768
|
);
|
|
@@ -198,7 +198,11 @@ export function $ControllerProvider() {
|
|
|
198
198
|
);
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
instance = $injector.instantiate(
|
|
201
|
+
instance = $injector.instantiate(
|
|
202
|
+
/** @type {Function} */ (expression),
|
|
203
|
+
locals,
|
|
204
|
+
constructor,
|
|
205
|
+
);
|
|
202
206
|
|
|
203
207
|
if (identifier) {
|
|
204
208
|
addIdentifier(
|
|
@@ -28,7 +28,7 @@ describe("$$cookieReader", () => {
|
|
|
28
28
|
expect(document.cookie).toEqual("");
|
|
29
29
|
|
|
30
30
|
window.angular = new Angular();
|
|
31
|
-
|
|
31
|
+
const injector = createInjector(["ng"]);
|
|
32
32
|
$$cookieReader = injector.get("$$cookieReader");
|
|
33
33
|
});
|
|
34
34
|
|
package/src/core/di/injector.js
CHANGED
|
@@ -247,7 +247,7 @@ function extractArgs(fn) {
|
|
|
247
247
|
* @returns {Array<string>}
|
|
248
248
|
*/
|
|
249
249
|
export function annotate(fn, strictDi, name) {
|
|
250
|
-
|
|
250
|
+
let $inject, argDecl, last;
|
|
251
251
|
|
|
252
252
|
if (typeof fn === "function") {
|
|
253
253
|
if (!($inject = fn.$inject)) {
|
|
@@ -1164,42 +1164,42 @@ describe("factories", () => {
|
|
|
1164
1164
|
beforeEach(() => (window.angular = new Angular()));
|
|
1165
1165
|
|
|
1166
1166
|
it("allows registering a factory", function () {
|
|
1167
|
-
|
|
1167
|
+
const module = angular.module("myModule", []);
|
|
1168
1168
|
module.factory("a", function () {
|
|
1169
1169
|
return 42;
|
|
1170
1170
|
});
|
|
1171
|
-
|
|
1171
|
+
const injector = createInjector(["myModule"]);
|
|
1172
1172
|
expect(injector.get("a")).toBe(42);
|
|
1173
1173
|
});
|
|
1174
1174
|
|
|
1175
1175
|
it("injects a factory function with instances", function () {
|
|
1176
|
-
|
|
1176
|
+
const module = angular.module("myModule", []);
|
|
1177
1177
|
module.factory("a", function () {
|
|
1178
1178
|
return 1;
|
|
1179
1179
|
});
|
|
1180
1180
|
module.factory("b", function (a) {
|
|
1181
1181
|
return a + 2;
|
|
1182
1182
|
});
|
|
1183
|
-
|
|
1183
|
+
const injector = createInjector(["myModule"]);
|
|
1184
1184
|
expect(injector.get("b")).toBe(3);
|
|
1185
1185
|
});
|
|
1186
1186
|
|
|
1187
1187
|
it("only calls a factory function once", function () {
|
|
1188
|
-
|
|
1188
|
+
const module = angular.module("myModule", []);
|
|
1189
1189
|
module.factory("a", function () {
|
|
1190
1190
|
return {};
|
|
1191
1191
|
});
|
|
1192
|
-
|
|
1192
|
+
const injector = createInjector(["myModule"]);
|
|
1193
1193
|
expect(injector.get("a")).toBe(injector.get("a"));
|
|
1194
1194
|
});
|
|
1195
1195
|
|
|
1196
1196
|
it("forces a factory to return a value", function () {
|
|
1197
|
-
|
|
1197
|
+
const module = angular.module("myModule", []);
|
|
1198
1198
|
module.factory("a", function () {});
|
|
1199
1199
|
module.factory("b", function () {
|
|
1200
1200
|
return null;
|
|
1201
1201
|
});
|
|
1202
|
-
|
|
1202
|
+
const injector = createInjector(["myModule"]);
|
|
1203
1203
|
expect(function () {
|
|
1204
1204
|
injector.get("a");
|
|
1205
1205
|
}).toThrow();
|
|
@@ -1224,14 +1224,14 @@ describe("values", () => {
|
|
|
1224
1224
|
beforeEach(() => (window.angular = new Angular()));
|
|
1225
1225
|
|
|
1226
1226
|
it("allows registering a value", function () {
|
|
1227
|
-
|
|
1227
|
+
const module = angular.module("myModule", []);
|
|
1228
1228
|
module.value("a", 42);
|
|
1229
|
-
|
|
1229
|
+
const injector = createInjector(["myModule"]);
|
|
1230
1230
|
expect(injector.get("a")).toBe(42);
|
|
1231
1231
|
});
|
|
1232
1232
|
|
|
1233
1233
|
it("does not make values available to config blocks", function () {
|
|
1234
|
-
|
|
1234
|
+
const module = angular.module("myModule", []);
|
|
1235
1235
|
module.value("a", 42);
|
|
1236
1236
|
module.config(function (a) {});
|
|
1237
1237
|
expect(function () {
|
|
@@ -1240,9 +1240,9 @@ describe("values", () => {
|
|
|
1240
1240
|
});
|
|
1241
1241
|
|
|
1242
1242
|
it("allows an undefined value", function () {
|
|
1243
|
-
|
|
1243
|
+
const module = angular.module("myModule", []);
|
|
1244
1244
|
module.value("a", undefined);
|
|
1245
|
-
|
|
1245
|
+
const injector = createInjector(["myModule"]);
|
|
1246
1246
|
expect(injector.get("a")).toBeUndefined();
|
|
1247
1247
|
});
|
|
1248
1248
|
});
|
|
@@ -1251,30 +1251,30 @@ describe("services", () => {
|
|
|
1251
1251
|
beforeEach(() => (window.angular = new Angular()));
|
|
1252
1252
|
|
|
1253
1253
|
it("allows registering a service", function () {
|
|
1254
|
-
|
|
1254
|
+
const module = angular.module("myModule", []);
|
|
1255
1255
|
module.service("aService", function MyService() {
|
|
1256
1256
|
this.getValue = function () {
|
|
1257
1257
|
return 42;
|
|
1258
1258
|
};
|
|
1259
1259
|
});
|
|
1260
|
-
|
|
1260
|
+
const injector = createInjector(["myModule"]);
|
|
1261
1261
|
expect(injector.get("aService").getValue()).toBe(42);
|
|
1262
1262
|
});
|
|
1263
1263
|
|
|
1264
1264
|
it("injects service constructors with instances", function () {
|
|
1265
|
-
|
|
1265
|
+
const module = angular.module("myModule", []);
|
|
1266
1266
|
module.value("theValue", 42);
|
|
1267
1267
|
module.service("aService", function MyService(theValue) {
|
|
1268
1268
|
this.getValue = function () {
|
|
1269
1269
|
return theValue;
|
|
1270
1270
|
};
|
|
1271
1271
|
});
|
|
1272
|
-
|
|
1272
|
+
const injector = createInjector(["myModule"]);
|
|
1273
1273
|
expect(injector.get("aService").getValue()).toBe(42);
|
|
1274
1274
|
});
|
|
1275
1275
|
|
|
1276
1276
|
it("injects service ES6 constructors with instances", function () {
|
|
1277
|
-
|
|
1277
|
+
const module = angular.module("myModule", []);
|
|
1278
1278
|
module.value("theValue", 42);
|
|
1279
1279
|
module.service(
|
|
1280
1280
|
"aService",
|
|
@@ -1287,14 +1287,14 @@ describe("services", () => {
|
|
|
1287
1287
|
}
|
|
1288
1288
|
},
|
|
1289
1289
|
);
|
|
1290
|
-
|
|
1290
|
+
const injector = createInjector(["myModule"]);
|
|
1291
1291
|
expect(injector.get("aService").getValue()).toBe(42);
|
|
1292
1292
|
});
|
|
1293
1293
|
|
|
1294
1294
|
it("only instantiates services once", function () {
|
|
1295
|
-
|
|
1295
|
+
const module = angular.module("myModule", []);
|
|
1296
1296
|
module.service("aService", function MyService() {});
|
|
1297
|
-
|
|
1297
|
+
const injector = createInjector(["myModule"]);
|
|
1298
1298
|
expect(injector.get("aService")).toBe(injector.get("aService"));
|
|
1299
1299
|
});
|
|
1300
1300
|
});
|
|
@@ -1303,7 +1303,7 @@ describe("decorators", () => {
|
|
|
1303
1303
|
beforeEach(() => (window.angular = new Angular()));
|
|
1304
1304
|
|
|
1305
1305
|
it("allows changing an instance using a decorator", function () {
|
|
1306
|
-
|
|
1306
|
+
const module = angular.module("myModule", []);
|
|
1307
1307
|
module.factory("aValue", function () {
|
|
1308
1308
|
return { aKey: 42 };
|
|
1309
1309
|
});
|
|
@@ -1311,14 +1311,14 @@ describe("decorators", () => {
|
|
|
1311
1311
|
$delegate.decoratedKey = 43;
|
|
1312
1312
|
return $delegate;
|
|
1313
1313
|
});
|
|
1314
|
-
|
|
1314
|
+
const injector = createInjector(["myModule"]);
|
|
1315
1315
|
|
|
1316
1316
|
expect(injector.get("aValue").aKey).toBe(42);
|
|
1317
1317
|
expect(injector.get("aValue").decoratedKey).toBe(43);
|
|
1318
1318
|
});
|
|
1319
1319
|
|
|
1320
1320
|
it("allows multiple decorators per service", function () {
|
|
1321
|
-
|
|
1321
|
+
const module = angular.module("myModule", []);
|
|
1322
1322
|
module.factory("aValue", function () {
|
|
1323
1323
|
return {};
|
|
1324
1324
|
});
|
|
@@ -1330,13 +1330,13 @@ describe("decorators", () => {
|
|
|
1330
1330
|
$delegate.otherDecoratedKey = 43;
|
|
1331
1331
|
return $delegate;
|
|
1332
1332
|
});
|
|
1333
|
-
|
|
1333
|
+
const injector = createInjector(["myModule"]);
|
|
1334
1334
|
expect(injector.get("aValue").decoratedKey).toBe(42);
|
|
1335
1335
|
expect(injector.get("aValue").otherDecoratedKey).toBe(43);
|
|
1336
1336
|
});
|
|
1337
1337
|
|
|
1338
1338
|
it("uses dependency injection with decorators", function () {
|
|
1339
|
-
|
|
1339
|
+
const module = angular.module("myModule", []);
|
|
1340
1340
|
module.factory("aValue", function () {
|
|
1341
1341
|
return {};
|
|
1342
1342
|
});
|
|
@@ -1345,7 +1345,7 @@ describe("decorators", () => {
|
|
|
1345
1345
|
$delegate.decoratedKey = a;
|
|
1346
1346
|
return $delegate;
|
|
1347
1347
|
});
|
|
1348
|
-
|
|
1348
|
+
const injector = createInjector(["myModule"]);
|
|
1349
1349
|
expect(injector.get("aValue").decoratedKey).toBe(42);
|
|
1350
1350
|
});
|
|
1351
1351
|
});
|
|
@@ -2180,7 +2180,7 @@ describe("service instantiation", () => {
|
|
|
2180
2180
|
"should instantiate object and preserve constructor property and be instanceof " +
|
|
2181
2181
|
"with the array annotated type",
|
|
2182
2182
|
() => {
|
|
2183
|
-
|
|
2183
|
+
const t = $injector.instantiate(["book", "author", Type]);
|
|
2184
2184
|
expect(t.book).toEqual("moby");
|
|
2185
2185
|
expect(t.author).toEqual("melville");
|
|
2186
2186
|
expect(t.title()).toEqual("melville: moby");
|
|
@@ -2189,8 +2189,8 @@ describe("service instantiation", () => {
|
|
|
2189
2189
|
);
|
|
2190
2190
|
|
|
2191
2191
|
it("should allow constructor to return different object", () => {
|
|
2192
|
-
|
|
2193
|
-
|
|
2192
|
+
const obj = {};
|
|
2193
|
+
const Class = function () {
|
|
2194
2194
|
return obj;
|
|
2195
2195
|
};
|
|
2196
2196
|
|
|
@@ -2198,8 +2198,8 @@ describe("service instantiation", () => {
|
|
|
2198
2198
|
});
|
|
2199
2199
|
|
|
2200
2200
|
it("should allow constructor to return a function", () => {
|
|
2201
|
-
|
|
2202
|
-
|
|
2201
|
+
const fn = function () {};
|
|
2202
|
+
const Class = function () {
|
|
2203
2203
|
return fn;
|
|
2204
2204
|
};
|
|
2205
2205
|
|
|
@@ -2215,15 +2215,15 @@ describe("service instantiation", () => {
|
|
|
2215
2215
|
});
|
|
2216
2216
|
|
|
2217
2217
|
it("should return instance if constructor returns non-object value", () => {
|
|
2218
|
-
|
|
2218
|
+
const A = function () {
|
|
2219
2219
|
return 10;
|
|
2220
2220
|
};
|
|
2221
2221
|
|
|
2222
|
-
|
|
2222
|
+
const B = function () {
|
|
2223
2223
|
return "some-string";
|
|
2224
2224
|
};
|
|
2225
2225
|
|
|
2226
|
-
|
|
2226
|
+
const C = function () {
|
|
2227
2227
|
return undefined;
|
|
2228
2228
|
};
|
|
2229
2229
|
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { Angular } from "../../loader";
|
|
2
|
-
import { createInjector } from "
|
|
2
|
+
import { createInjector } from "../di/injector";
|
|
3
3
|
|
|
4
4
|
describe("filter", function () {
|
|
5
5
|
beforeEach(() => {
|
|
6
6
|
window.angular = new Angular();
|
|
7
7
|
});
|
|
8
8
|
it("can be registered and obtained", () => {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const myFilter = () => {};
|
|
10
|
+
const myFilterFactory = () => {
|
|
11
11
|
return myFilter;
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
const injector = createInjector([
|
|
14
14
|
"ng",
|
|
15
15
|
function ($filterProvider) {
|
|
16
16
|
$filterProvider.register("my", myFilterFactory);
|
|
17
17
|
},
|
|
18
18
|
]);
|
|
19
|
-
|
|
19
|
+
const $filter = injector.get("$filter");
|
|
20
20
|
expect($filter("my")).toBe(myFilter);
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
it("allows registering multiple filters with an object", () => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const myFilter = () => {};
|
|
25
|
+
const myOtherFilter = () => {};
|
|
26
|
+
const injector = createInjector([
|
|
27
27
|
"ng",
|
|
28
28
|
function ($filterProvider) {
|
|
29
29
|
$filterProvider.register({
|
|
@@ -36,14 +36,14 @@ describe("filter", function () {
|
|
|
36
36
|
});
|
|
37
37
|
},
|
|
38
38
|
]);
|
|
39
|
-
|
|
39
|
+
const $filter = injector.get("$filter");
|
|
40
40
|
expect($filter("my")).toBe(myFilter);
|
|
41
41
|
expect($filter("myOther")).toBe(myOtherFilter);
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
it("is available through injector", () => {
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
const myFilter = () => {};
|
|
46
|
+
const injector = createInjector([
|
|
47
47
|
"ng",
|
|
48
48
|
function ($filterProvider) {
|
|
49
49
|
$filterProvider.register("my", () => {
|
|
@@ -56,7 +56,7 @@ describe("filter", function () {
|
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
it("may have dependencies in factory", () => {
|
|
59
|
-
|
|
59
|
+
const injector = createInjector([
|
|
60
60
|
"ng",
|
|
61
61
|
function ($provide, $filterProvider) {
|
|
62
62
|
$provide.constant("suffix", "!");
|
|
@@ -71,11 +71,11 @@ describe("filter", function () {
|
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
it("can be registered through module API", () => {
|
|
74
|
-
|
|
74
|
+
const myFilter = () => {};
|
|
75
75
|
angular.module("myModule", []).filter("my", () => {
|
|
76
76
|
return myFilter;
|
|
77
77
|
});
|
|
78
|
-
|
|
78
|
+
const injector = createInjector(["ng", "myModule"]);
|
|
79
79
|
expect(injector.has("myFilter")).toBe(true);
|
|
80
80
|
expect(injector.get("myFilter")).toBe(myFilter);
|
|
81
81
|
});
|
|
@@ -86,7 +86,7 @@ describe("filter filter", function () {
|
|
|
86
86
|
window.angular = new Angular();
|
|
87
87
|
});
|
|
88
88
|
it("is available", function () {
|
|
89
|
-
|
|
89
|
+
const injector = createInjector(["ng"]);
|
|
90
90
|
expect(injector.has("filterFilter")).toBe(true);
|
|
91
91
|
});
|
|
92
92
|
// TODO
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createInjector } from "
|
|
1
|
+
import { createInjector } from "../di/injector";
|
|
2
2
|
import { Angular } from "../../loader";
|
|
3
3
|
|
|
4
4
|
describe("$interpolate", () => {
|
|
@@ -13,70 +13,70 @@ describe("$interpolate", () => {
|
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
it("produces an identity function for static content", function () {
|
|
16
|
-
|
|
16
|
+
const interp = $interpolate("hello");
|
|
17
17
|
expect(interp instanceof Function).toBe(true);
|
|
18
18
|
expect(interp()).toEqual("hello");
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
it("evaluates a single expression", function () {
|
|
22
|
-
|
|
22
|
+
const interp = $interpolate("{{anAttr}}");
|
|
23
23
|
expect(interp({ anAttr: "42" })).toEqual("42");
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
it("passes through ill-defined interpolations", function () {
|
|
27
|
-
|
|
27
|
+
const interp = $interpolate("why u no }}work{{");
|
|
28
28
|
expect(interp({})).toEqual("why u no }}work{{");
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
it("evaluates many expressions", function () {
|
|
32
|
-
|
|
32
|
+
const interp = $interpolate("First {{anAttr}}, then {{anotherAttr}}!");
|
|
33
33
|
expect(interp({ anAttr: "42", anotherAttr: "43" })).toEqual(
|
|
34
34
|
"First 42, then 43!",
|
|
35
35
|
);
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
it("turns nulls into empty strings", function () {
|
|
39
|
-
|
|
39
|
+
const interp = $interpolate("{{aNull}}");
|
|
40
40
|
expect(interp({ aNull: null })).toEqual("");
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
it("turns undefineds into empty strings", function () {
|
|
44
|
-
|
|
44
|
+
const interp = $interpolate("{{anUndefined}}");
|
|
45
45
|
expect(interp({})).toEqual("");
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
it("turns numbers into strings", function () {
|
|
49
|
-
|
|
49
|
+
const interp = $interpolate("{{aNumber}}");
|
|
50
50
|
expect(interp({ aNumber: 42 })).toEqual("42");
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
it("turns booleans into strings", function () {
|
|
54
|
-
|
|
54
|
+
const interp = $interpolate("{{aBoolean}}");
|
|
55
55
|
expect(interp({ aBoolean: true })).toEqual("true");
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
it("turns arrays into JSON strings", function () {
|
|
59
|
-
|
|
59
|
+
const interp = $interpolate("{{anArray}}");
|
|
60
60
|
expect(interp({ anArray: [1, 2, [3]] })).toEqual("[1,2,[3]]");
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
it("turns objects into JSON strings", function () {
|
|
64
|
-
|
|
64
|
+
const interp = $interpolate("{{anObject}}");
|
|
65
65
|
expect(interp({ anObject: { a: 1, b: "2" } })).toEqual('{"a":1,"b":"2"}');
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
it("unescapes escaped sequences", function () {
|
|
69
|
-
|
|
69
|
+
const interp = $interpolate("\\{\\{expr\\}\\} {{expr}} \\{\\{expr\\}\\}");
|
|
70
70
|
expect(interp({ expr: "value" })).toEqual("{{expr}} value {{expr}}");
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
it("does not return function when flagged and no expressions", function () {
|
|
74
|
-
|
|
74
|
+
const interp = $interpolate("static content only", true);
|
|
75
75
|
expect(interp).toBeFalsy();
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
it("returns function when flagged and has expressions", function () {
|
|
79
|
-
|
|
79
|
+
const interp = $interpolate("has an {{expr}}", true);
|
|
80
80
|
expect(interp).not.toBeFalsy();
|
|
81
81
|
});
|
|
82
82
|
|
|
@@ -253,20 +253,20 @@ describe("$interpolate", () => {
|
|
|
253
253
|
|
|
254
254
|
describe("interpolation escaping", () => {
|
|
255
255
|
let obj;
|
|
256
|
-
|
|
256
|
+
let $compile;
|
|
257
257
|
beforeEach(() => {
|
|
258
258
|
obj = { foo: "Hello", bar: "World" };
|
|
259
259
|
$compile = $injector.get("$compile");
|
|
260
260
|
});
|
|
261
261
|
|
|
262
262
|
it("uses a watch delegate", function () {
|
|
263
|
-
|
|
263
|
+
const interp = $interpolate("has an {{expr}}");
|
|
264
264
|
expect(interp.$$watchDelegate).toBeDefined();
|
|
265
265
|
});
|
|
266
266
|
|
|
267
267
|
it("correctly returns new and old value when watched", function () {
|
|
268
|
-
|
|
269
|
-
|
|
268
|
+
const interp = $interpolate("{{expr}}");
|
|
269
|
+
const listenerSpy = jasmine.createSpy();
|
|
270
270
|
$rootScope.$watch(interp, listenerSpy);
|
|
271
271
|
$rootScope.expr = 42;
|
|
272
272
|
$rootScope.$apply();
|
|
@@ -341,50 +341,50 @@ describe("$interpolate", () => {
|
|
|
341
341
|
});
|
|
342
342
|
|
|
343
343
|
it("allows configuring start and end symbols", function () {
|
|
344
|
-
|
|
344
|
+
const injector = createInjector([
|
|
345
345
|
"ng",
|
|
346
346
|
function ($interpolateProvider) {
|
|
347
347
|
$interpolateProvider.startSymbol("FOO").endSymbol("OOF");
|
|
348
348
|
},
|
|
349
349
|
]);
|
|
350
|
-
|
|
350
|
+
const $interpolate = injector.get("$interpolate");
|
|
351
351
|
expect($interpolate.startSymbol()).toEqual("FOO");
|
|
352
352
|
expect($interpolate.endSymbol()).toEqual("OOF");
|
|
353
353
|
});
|
|
354
354
|
|
|
355
355
|
it("works with start and end symbols that differ from default", function () {
|
|
356
|
-
|
|
356
|
+
const injector = createInjector([
|
|
357
357
|
"ng",
|
|
358
358
|
function ($interpolateProvider) {
|
|
359
359
|
$interpolateProvider.startSymbol("FOO").endSymbol("OOF");
|
|
360
360
|
},
|
|
361
361
|
]);
|
|
362
|
-
|
|
363
|
-
|
|
362
|
+
const $interpolate = injector.get("$interpolate");
|
|
363
|
+
const interpFn = $interpolate("FOOmyExprOOF");
|
|
364
364
|
expect(interpFn({ myExpr: 42 })).toEqual("42");
|
|
365
365
|
});
|
|
366
366
|
|
|
367
367
|
it("does not work with default symbols when reconfigured", function () {
|
|
368
|
-
|
|
368
|
+
const injector = createInjector([
|
|
369
369
|
"ng",
|
|
370
370
|
function ($interpolateProvider) {
|
|
371
371
|
$interpolateProvider.startSymbol("FOO").endSymbol("OOF");
|
|
372
372
|
},
|
|
373
373
|
]);
|
|
374
|
-
|
|
375
|
-
|
|
374
|
+
const $interpolate = injector.get("$interpolate");
|
|
375
|
+
const interpFn = $interpolate("{{myExpr}}");
|
|
376
376
|
expect(interpFn({ myExpr: 42 })).toEqual("{{myExpr}}");
|
|
377
377
|
});
|
|
378
378
|
|
|
379
379
|
it("supports unescaping for reconfigured symbols", function () {
|
|
380
|
-
|
|
380
|
+
const injector = createInjector([
|
|
381
381
|
"ng",
|
|
382
382
|
function ($interpolateProvider) {
|
|
383
383
|
$interpolateProvider.startSymbol("FOO").endSymbol("OOF");
|
|
384
384
|
},
|
|
385
385
|
]);
|
|
386
|
-
|
|
387
|
-
|
|
386
|
+
const $interpolate = injector.get("$interpolate");
|
|
387
|
+
const interpFn = $interpolate("\\F\\O\\OmyExpr\\O\\O\\F");
|
|
388
388
|
expect(interpFn({})).toEqual("FOOmyExprOOF");
|
|
389
389
|
});
|
|
390
390
|
|