@microsoft/fast-html 1.0.0-alpha.19 → 1.0.0-alpha.20
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/README.md +3 -19
- package/dist/dts/components/observer-map.d.ts +3 -120
- package/dist/dts/components/schema.d.ts +23 -15
- package/dist/dts/components/template.d.ts +1 -5
- package/dist/dts/components/utilities.d.ts +33 -69
- package/dist/esm/components/observer-map.js +10 -512
- package/dist/esm/components/observer-map.spec.js +5 -599
- package/dist/esm/components/schema.js +39 -20
- package/dist/esm/components/schema.spec.js +9 -0
- package/dist/esm/components/template.js +31 -50
- package/dist/esm/components/utilities.js +202 -179
- package/dist/esm/components/utilities.spec.js +6 -29
- package/dist/esm/fixtures/repeat/main.js +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/fast-html.api.json +13 -126
- package/dist/fast-html.d.ts +118 -150
- package/dist/fast-html.untrimmed.d.ts +118 -150
- package/package.json +2 -3
- package/dist/dts/fixtures/partial/main.d.ts +0 -1
- package/dist/dts/fixtures/partial/partial.spec.d.ts +0 -1
- package/dist/esm/fixtures/partial/main.js +0 -32
- package/dist/esm/fixtures/partial/partial.spec.js +0 -14
|
@@ -1,613 +1,19 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import { expect, test } from "@playwright/test";
|
|
3
3
|
import { ObserverMap } from "./observer-map.js";
|
|
4
|
+
import { Schema } from "./schema.js";
|
|
4
5
|
test.describe("ObserverMap", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
5
6
|
let observerMap;
|
|
7
|
+
let schema = new Schema("test-class");
|
|
6
8
|
class TestClass {
|
|
7
9
|
}
|
|
8
10
|
test.beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
9
11
|
// Use TestClass.prototype so instances will have the observable properties
|
|
10
|
-
observerMap = new ObserverMap(TestClass.prototype);
|
|
12
|
+
observerMap = new ObserverMap(TestClass.prototype, schema);
|
|
11
13
|
}));
|
|
12
14
|
test("should create new instances", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
|
-
const instance1 = new ObserverMap(TestClass.prototype);
|
|
14
|
-
const instance2 = new ObserverMap(TestClass.prototype);
|
|
15
|
+
const instance1 = new ObserverMap(TestClass.prototype, schema);
|
|
16
|
+
const instance2 = new ObserverMap(TestClass.prototype, schema);
|
|
15
17
|
expect(instance1).not.toBe(instance2);
|
|
16
18
|
}));
|
|
17
|
-
test.describe("should calculate an absolute path", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
-
test("when the level is 0 and no context path is provided", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
-
expect(observerMap.getAbsolutePath({
|
|
20
|
-
path: "a",
|
|
21
|
-
self: false,
|
|
22
|
-
level: 0,
|
|
23
|
-
parentContext: null,
|
|
24
|
-
contextPath: null,
|
|
25
|
-
type: "access",
|
|
26
|
-
rootPath: null,
|
|
27
|
-
context: null,
|
|
28
|
-
})).toEqual("a");
|
|
29
|
-
}));
|
|
30
|
-
test("when the level is at 2 and the path is 2 levels up and no context path is provided", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
-
expect(observerMap.getAbsolutePath({
|
|
32
|
-
path: "../../a",
|
|
33
|
-
self: false,
|
|
34
|
-
level: 2,
|
|
35
|
-
parentContext: null,
|
|
36
|
-
contextPath: null,
|
|
37
|
-
type: "access",
|
|
38
|
-
rootPath: null,
|
|
39
|
-
context: null,
|
|
40
|
-
})).toEqual("a");
|
|
41
|
-
}));
|
|
42
|
-
test("when the level is at 2 and the path is 1 level up with a multi-level of context path", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
-
expect(observerMap.getAbsolutePath({
|
|
44
|
-
path: "../a",
|
|
45
|
-
self: false,
|
|
46
|
-
level: 2,
|
|
47
|
-
parentContext: null,
|
|
48
|
-
contextPath: "b.c.d",
|
|
49
|
-
type: "access",
|
|
50
|
-
rootPath: null,
|
|
51
|
-
context: null,
|
|
52
|
-
})).toEqual("b.c.a");
|
|
53
|
-
}));
|
|
54
|
-
test("when the level is at 2 and the path is 0 levels up with a multi-level context path", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
-
expect(observerMap.getAbsolutePath({
|
|
56
|
-
path: "a",
|
|
57
|
-
self: false,
|
|
58
|
-
level: 2,
|
|
59
|
-
parentContext: null,
|
|
60
|
-
contextPath: "b.c.d",
|
|
61
|
-
type: "access",
|
|
62
|
-
rootPath: null,
|
|
63
|
-
context: null,
|
|
64
|
-
})).toEqual("b.a");
|
|
65
|
-
}));
|
|
66
|
-
test("when the level is at 2 and the path is 1 level up with a single level context path", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
67
|
-
expect(observerMap.getAbsolutePath({
|
|
68
|
-
path: "../a",
|
|
69
|
-
self: false,
|
|
70
|
-
level: 2,
|
|
71
|
-
parentContext: null,
|
|
72
|
-
contextPath: "b",
|
|
73
|
-
type: "access",
|
|
74
|
-
rootPath: null,
|
|
75
|
-
context: null,
|
|
76
|
-
})).toEqual("a");
|
|
77
|
-
}));
|
|
78
|
-
test("when the level is 0 and the path is 0 a context has been provided and a repeat type", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
|
-
expect(observerMap.getAbsolutePath({
|
|
80
|
-
path: "items",
|
|
81
|
-
self: false,
|
|
82
|
-
level: 0,
|
|
83
|
-
parentContext: null,
|
|
84
|
-
contextPath: "item",
|
|
85
|
-
type: "repeat",
|
|
86
|
-
rootPath: null,
|
|
87
|
-
context: null,
|
|
88
|
-
})).toEqual("items");
|
|
89
|
-
}));
|
|
90
|
-
test("when the item refers to itself", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
91
|
-
expect(observerMap.getAbsolutePath({
|
|
92
|
-
path: "item.a",
|
|
93
|
-
self: true,
|
|
94
|
-
level: 1,
|
|
95
|
-
parentContext: null,
|
|
96
|
-
contextPath: "items",
|
|
97
|
-
type: "access",
|
|
98
|
-
rootPath: null,
|
|
99
|
-
context: null,
|
|
100
|
-
})).toEqual("items.__index__.a");
|
|
101
|
-
}));
|
|
102
|
-
test("when a parent context is given", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
103
|
-
/**
|
|
104
|
-
* This should create a "users" context, which in turn should create an "items" context,
|
|
105
|
-
* these should have Symbol references to each other
|
|
106
|
-
*/
|
|
107
|
-
observerMap.cachePathWithContext({
|
|
108
|
-
path: "users",
|
|
109
|
-
self: false,
|
|
110
|
-
parentContext: null,
|
|
111
|
-
contextPath: "user",
|
|
112
|
-
type: "repeat",
|
|
113
|
-
level: 0,
|
|
114
|
-
rootPath: null,
|
|
115
|
-
context: null,
|
|
116
|
-
});
|
|
117
|
-
observerMap.cachePathWithContext({
|
|
118
|
-
path: "items",
|
|
119
|
-
self: true,
|
|
120
|
-
parentContext: "user",
|
|
121
|
-
contextPath: "item",
|
|
122
|
-
type: "repeat",
|
|
123
|
-
level: 1,
|
|
124
|
-
rootPath: null,
|
|
125
|
-
context: null,
|
|
126
|
-
});
|
|
127
|
-
observerMap.cachePathWithContext({
|
|
128
|
-
path: "item.a",
|
|
129
|
-
self: true,
|
|
130
|
-
parentContext: "item",
|
|
131
|
-
contextPath: null,
|
|
132
|
-
type: "access",
|
|
133
|
-
level: 2,
|
|
134
|
-
rootPath: null,
|
|
135
|
-
context: null,
|
|
136
|
-
});
|
|
137
|
-
expect(observerMap.getAbsolutePath({
|
|
138
|
-
path: "item.a",
|
|
139
|
-
self: true,
|
|
140
|
-
level: 1,
|
|
141
|
-
parentContext: "user",
|
|
142
|
-
contextPath: "items",
|
|
143
|
-
type: "access",
|
|
144
|
-
rootPath: null,
|
|
145
|
-
context: null,
|
|
146
|
-
})).toEqual("users.__index__.items.__index__.a");
|
|
147
|
-
}));
|
|
148
|
-
}));
|
|
149
|
-
test.describe("should cache paths with contexts", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
150
|
-
test("should cache a path", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
151
|
-
observerMap.cachePathWithContext({
|
|
152
|
-
path: "a",
|
|
153
|
-
self: false,
|
|
154
|
-
parentContext: null,
|
|
155
|
-
contextPath: null,
|
|
156
|
-
type: "access",
|
|
157
|
-
level: 0,
|
|
158
|
-
rootPath: null,
|
|
159
|
-
context: null,
|
|
160
|
-
});
|
|
161
|
-
const cachedPathsWithContext = observerMap.getCachedPathsWithContext();
|
|
162
|
-
expect(cachedPathsWithContext["a"]).toBeDefined();
|
|
163
|
-
expect(cachedPathsWithContext["a"].type).toEqual("default");
|
|
164
|
-
expect(cachedPathsWithContext["a"].paths["a"]).toBeDefined();
|
|
165
|
-
expect(cachedPathsWithContext["a"].paths["a"].type).toEqual("access");
|
|
166
|
-
expect(cachedPathsWithContext["a"].paths["a"].relativePath).toEqual("a");
|
|
167
|
-
expect(cachedPathsWithContext["a"].paths["a"].absolutePath).toEqual("a");
|
|
168
|
-
}));
|
|
169
|
-
test("should cache a nested path", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
170
|
-
observerMap.cachePathWithContext({
|
|
171
|
-
path: "a.b.c",
|
|
172
|
-
self: false,
|
|
173
|
-
parentContext: null,
|
|
174
|
-
contextPath: null,
|
|
175
|
-
type: "access",
|
|
176
|
-
level: 0,
|
|
177
|
-
rootPath: null,
|
|
178
|
-
context: null,
|
|
179
|
-
});
|
|
180
|
-
const cachedPathsWithContext = observerMap.getCachedPathsWithContext();
|
|
181
|
-
expect(cachedPathsWithContext["a"]).toBeDefined();
|
|
182
|
-
expect(cachedPathsWithContext["a"].type).toEqual("default");
|
|
183
|
-
expect(cachedPathsWithContext["a"].paths["a.b.c"]).toBeDefined();
|
|
184
|
-
expect(cachedPathsWithContext["a"].paths["a.b.c"].type).toEqual("access");
|
|
185
|
-
expect(cachedPathsWithContext["a"].paths["a.b.c"].relativePath).toEqual("a.b.c");
|
|
186
|
-
expect(cachedPathsWithContext["a"].paths["a.b.c"].absolutePath).toEqual("a.b.c");
|
|
187
|
-
}));
|
|
188
|
-
test("should cache multiple paths", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
189
|
-
observerMap.cachePathWithContext({
|
|
190
|
-
path: "a.b.c",
|
|
191
|
-
self: false,
|
|
192
|
-
parentContext: null,
|
|
193
|
-
contextPath: null,
|
|
194
|
-
type: "access",
|
|
195
|
-
level: 0,
|
|
196
|
-
rootPath: null,
|
|
197
|
-
context: null,
|
|
198
|
-
});
|
|
199
|
-
observerMap.cachePathWithContext({
|
|
200
|
-
path: "a.b.d",
|
|
201
|
-
self: false,
|
|
202
|
-
parentContext: null,
|
|
203
|
-
contextPath: null,
|
|
204
|
-
type: "access",
|
|
205
|
-
level: 0,
|
|
206
|
-
rootPath: null,
|
|
207
|
-
context: null,
|
|
208
|
-
});
|
|
209
|
-
const cachedPathsWithContext = observerMap.getCachedPathsWithContext();
|
|
210
|
-
expect(cachedPathsWithContext["a"]).toBeDefined();
|
|
211
|
-
expect(cachedPathsWithContext["a"].type).toEqual("default");
|
|
212
|
-
expect(cachedPathsWithContext["a"].paths["a.b.c"]).toBeDefined();
|
|
213
|
-
expect(cachedPathsWithContext["a"].paths["a.b.c"].type).toEqual("access");
|
|
214
|
-
expect(cachedPathsWithContext["a"].paths["a.b.c"].relativePath).toEqual("a.b.c");
|
|
215
|
-
expect(cachedPathsWithContext["a"].paths["a.b.c"].absolutePath).toEqual("a.b.c");
|
|
216
|
-
expect(cachedPathsWithContext["a"].paths["a.b.d"]).toBeDefined();
|
|
217
|
-
expect(cachedPathsWithContext["a"].paths["a.b.d"].type).toEqual("access");
|
|
218
|
-
expect(cachedPathsWithContext["a"].paths["a.b.d"].relativePath).toEqual("a.b.d");
|
|
219
|
-
expect(cachedPathsWithContext["a"].paths["a.b.d"].absolutePath).toEqual("a.b.d");
|
|
220
|
-
}));
|
|
221
|
-
test("should cache a path with context", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
222
|
-
/**
|
|
223
|
-
* Example:
|
|
224
|
-
* <f-repeat value="{{item in items}}">
|
|
225
|
-
* {{item.a}}
|
|
226
|
-
* </f-repeat>
|
|
227
|
-
*/
|
|
228
|
-
observerMap.cachePathWithContext({
|
|
229
|
-
path: "items",
|
|
230
|
-
self: false,
|
|
231
|
-
parentContext: null,
|
|
232
|
-
contextPath: "item",
|
|
233
|
-
type: "repeat",
|
|
234
|
-
level: 0,
|
|
235
|
-
rootPath: null,
|
|
236
|
-
context: null,
|
|
237
|
-
});
|
|
238
|
-
observerMap.cachePathWithContext({
|
|
239
|
-
path: "item.a",
|
|
240
|
-
self: true,
|
|
241
|
-
parentContext: "item",
|
|
242
|
-
contextPath: null,
|
|
243
|
-
type: "access",
|
|
244
|
-
level: 1,
|
|
245
|
-
rootPath: null,
|
|
246
|
-
context: null,
|
|
247
|
-
});
|
|
248
|
-
const cachedPathsWithContext = observerMap.getCachedPathsWithContext();
|
|
249
|
-
expect(cachedPathsWithContext["items"]).toBeDefined();
|
|
250
|
-
expect(cachedPathsWithContext["items"].type).toEqual("repeat");
|
|
251
|
-
expect(cachedPathsWithContext["items"].context).toEqual("item");
|
|
252
|
-
expect(cachedPathsWithContext["items"].paths["item.a"]).toBeDefined();
|
|
253
|
-
expect(cachedPathsWithContext["items"].paths["item.a"].type).toEqual("access");
|
|
254
|
-
expect(cachedPathsWithContext["items"].paths["item.a"].relativePath).toEqual("item.a");
|
|
255
|
-
expect(cachedPathsWithContext["items"].paths["item.a"].absolutePath).toEqual("items.__index__.a");
|
|
256
|
-
}));
|
|
257
|
-
test("should cache a nested path with context", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
258
|
-
/**
|
|
259
|
-
* Example:
|
|
260
|
-
* <f-repeat value="{{item in root.items}}">
|
|
261
|
-
* {{item.a}}
|
|
262
|
-
* </f-repeat>
|
|
263
|
-
*/
|
|
264
|
-
observerMap.cachePathWithContext({
|
|
265
|
-
path: "root.items",
|
|
266
|
-
self: false,
|
|
267
|
-
parentContext: null,
|
|
268
|
-
contextPath: "item",
|
|
269
|
-
type: "repeat",
|
|
270
|
-
level: 0,
|
|
271
|
-
rootPath: null,
|
|
272
|
-
context: null,
|
|
273
|
-
});
|
|
274
|
-
observerMap.cachePathWithContext({
|
|
275
|
-
path: "item.a",
|
|
276
|
-
self: true,
|
|
277
|
-
parentContext: "item",
|
|
278
|
-
contextPath: null,
|
|
279
|
-
type: "access",
|
|
280
|
-
level: 1,
|
|
281
|
-
rootPath: null,
|
|
282
|
-
context: null,
|
|
283
|
-
});
|
|
284
|
-
const cachedPathsWithContext = observerMap.getCachedPathsWithContext();
|
|
285
|
-
expect(cachedPathsWithContext["root"]).toBeDefined();
|
|
286
|
-
expect(cachedPathsWithContext["root"].type).toEqual("default");
|
|
287
|
-
const root = cachedPathsWithContext["root"];
|
|
288
|
-
expect(root.paths["items"]).toBeDefined();
|
|
289
|
-
const items = root.paths["items"];
|
|
290
|
-
expect(items.type).toEqual("repeat");
|
|
291
|
-
expect(items.context).toEqual("item");
|
|
292
|
-
expect(items.paths["item.a"]).toBeDefined();
|
|
293
|
-
const itemA = items.paths["item.a"];
|
|
294
|
-
expect(itemA.type).toEqual("access");
|
|
295
|
-
expect(itemA.relativePath).toEqual("item.a");
|
|
296
|
-
expect(itemA.absolutePath).toEqual("root.items.__index__.a");
|
|
297
|
-
}));
|
|
298
|
-
test("should cache a nested repeat with nested path with context", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
299
|
-
/**
|
|
300
|
-
* Example:
|
|
301
|
-
* <f-repeat value="{{item in root.items}}">
|
|
302
|
-
* {{item.a}}
|
|
303
|
-
* <f-repeat value="{{subitem in item.subitems}}">
|
|
304
|
-
* {{subitem.title}}
|
|
305
|
-
* </f-repeat>
|
|
306
|
-
* </f-repeat>
|
|
307
|
-
*/
|
|
308
|
-
observerMap.cachePathWithContext({
|
|
309
|
-
path: "root.items",
|
|
310
|
-
self: false,
|
|
311
|
-
parentContext: null,
|
|
312
|
-
contextPath: "item",
|
|
313
|
-
type: "repeat",
|
|
314
|
-
level: 0,
|
|
315
|
-
rootPath: null,
|
|
316
|
-
context: null,
|
|
317
|
-
});
|
|
318
|
-
observerMap.cachePathWithContext({
|
|
319
|
-
path: "item.a",
|
|
320
|
-
self: true,
|
|
321
|
-
parentContext: "item",
|
|
322
|
-
contextPath: null,
|
|
323
|
-
type: "access",
|
|
324
|
-
level: 1,
|
|
325
|
-
rootPath: null,
|
|
326
|
-
context: null,
|
|
327
|
-
});
|
|
328
|
-
observerMap.cachePathWithContext({
|
|
329
|
-
path: "item.subitems",
|
|
330
|
-
self: true,
|
|
331
|
-
parentContext: "item",
|
|
332
|
-
contextPath: "subitem",
|
|
333
|
-
type: "repeat",
|
|
334
|
-
level: 1,
|
|
335
|
-
rootPath: null,
|
|
336
|
-
context: null,
|
|
337
|
-
});
|
|
338
|
-
observerMap.cachePathWithContext({
|
|
339
|
-
path: "subitem.title",
|
|
340
|
-
self: true,
|
|
341
|
-
parentContext: "subitem",
|
|
342
|
-
contextPath: null,
|
|
343
|
-
type: "access",
|
|
344
|
-
level: 2,
|
|
345
|
-
rootPath: null,
|
|
346
|
-
context: null,
|
|
347
|
-
});
|
|
348
|
-
const cachedPathsWithContext = observerMap.getCachedPathsWithContext();
|
|
349
|
-
expect(cachedPathsWithContext["root"]).toBeDefined();
|
|
350
|
-
expect(cachedPathsWithContext["root"].type).toEqual("default");
|
|
351
|
-
const root = cachedPathsWithContext["root"];
|
|
352
|
-
expect(root.paths["items"]).toBeDefined();
|
|
353
|
-
const items = root.paths["items"];
|
|
354
|
-
expect(items.type).toEqual("repeat");
|
|
355
|
-
expect(items.context).toEqual("item");
|
|
356
|
-
expect(items.paths["item.a"]).toBeDefined();
|
|
357
|
-
const itemA = items.paths["item.a"];
|
|
358
|
-
expect(itemA.type).toEqual("access");
|
|
359
|
-
expect(itemA.relativePath).toEqual("item.a");
|
|
360
|
-
expect(itemA.absolutePath).toEqual("root.items.__index__.a");
|
|
361
|
-
expect(items.paths["subitems"]).toBeDefined();
|
|
362
|
-
const subItems = items.paths["subitems"];
|
|
363
|
-
expect(subItems.type).toEqual("repeat");
|
|
364
|
-
expect(subItems.context).toEqual("subitem");
|
|
365
|
-
expect(subItems.paths["subitem.title"]).toBeDefined();
|
|
366
|
-
const subItemTitle = subItems.paths["subitem.title"];
|
|
367
|
-
expect(subItemTitle.type).toEqual("access");
|
|
368
|
-
expect(subItemTitle.relativePath).toEqual("subitem.title");
|
|
369
|
-
expect(subItemTitle.absolutePath).toEqual("root.items.__index__.subitems.__index__.title");
|
|
370
|
-
}));
|
|
371
|
-
test("should cache a multiple nested repeat with nested path with context", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
372
|
-
/**
|
|
373
|
-
* Example:
|
|
374
|
-
* <f-repeat value="{{item in root.items}}">
|
|
375
|
-
* {{item.a}}
|
|
376
|
-
* <f-repeat value="{{user in item.users}}">
|
|
377
|
-
* {{user.name}}
|
|
378
|
-
* <f-repeat value="{{badge in user.badges}}">
|
|
379
|
-
* {{badge}}
|
|
380
|
-
* </f-repeat>
|
|
381
|
-
* </f-repeat>
|
|
382
|
-
* <f-repeat value="{{setting in item.settings}}">
|
|
383
|
-
* {{setting.visibility}}
|
|
384
|
-
* </f-repeat>
|
|
385
|
-
* </f-repeat>
|
|
386
|
-
*/
|
|
387
|
-
observerMap.cachePathWithContext({
|
|
388
|
-
path: "root.items",
|
|
389
|
-
self: false,
|
|
390
|
-
parentContext: null,
|
|
391
|
-
contextPath: "item",
|
|
392
|
-
type: "repeat",
|
|
393
|
-
level: 0,
|
|
394
|
-
rootPath: null,
|
|
395
|
-
context: null,
|
|
396
|
-
});
|
|
397
|
-
observerMap.cachePathWithContext({
|
|
398
|
-
path: "item.a",
|
|
399
|
-
self: true,
|
|
400
|
-
parentContext: "item",
|
|
401
|
-
contextPath: null,
|
|
402
|
-
type: "access",
|
|
403
|
-
level: 1,
|
|
404
|
-
rootPath: null,
|
|
405
|
-
context: null,
|
|
406
|
-
});
|
|
407
|
-
observerMap.cachePathWithContext({
|
|
408
|
-
path: "item.users",
|
|
409
|
-
self: true,
|
|
410
|
-
parentContext: "item",
|
|
411
|
-
contextPath: "user",
|
|
412
|
-
type: "repeat",
|
|
413
|
-
level: 1,
|
|
414
|
-
rootPath: null,
|
|
415
|
-
context: null,
|
|
416
|
-
});
|
|
417
|
-
observerMap.cachePathWithContext({
|
|
418
|
-
path: "user.name",
|
|
419
|
-
self: true,
|
|
420
|
-
parentContext: "user",
|
|
421
|
-
contextPath: null,
|
|
422
|
-
type: "access",
|
|
423
|
-
level: 2,
|
|
424
|
-
rootPath: null,
|
|
425
|
-
context: null,
|
|
426
|
-
});
|
|
427
|
-
observerMap.cachePathWithContext({
|
|
428
|
-
path: "user.badges",
|
|
429
|
-
self: true,
|
|
430
|
-
parentContext: "user",
|
|
431
|
-
contextPath: "badge",
|
|
432
|
-
type: "repeat",
|
|
433
|
-
level: 2,
|
|
434
|
-
rootPath: null,
|
|
435
|
-
context: null,
|
|
436
|
-
});
|
|
437
|
-
observerMap.cachePathWithContext({
|
|
438
|
-
path: "badge",
|
|
439
|
-
self: true,
|
|
440
|
-
parentContext: "badge",
|
|
441
|
-
contextPath: null,
|
|
442
|
-
type: "access",
|
|
443
|
-
level: 3,
|
|
444
|
-
rootPath: null,
|
|
445
|
-
context: null,
|
|
446
|
-
});
|
|
447
|
-
observerMap.cachePathWithContext({
|
|
448
|
-
path: "item.settings",
|
|
449
|
-
self: true,
|
|
450
|
-
parentContext: "item",
|
|
451
|
-
contextPath: "setting",
|
|
452
|
-
type: "repeat",
|
|
453
|
-
level: 1,
|
|
454
|
-
rootPath: null,
|
|
455
|
-
context: null,
|
|
456
|
-
});
|
|
457
|
-
observerMap.cachePathWithContext({
|
|
458
|
-
path: "setting.visibility",
|
|
459
|
-
self: true,
|
|
460
|
-
parentContext: "setting",
|
|
461
|
-
contextPath: null,
|
|
462
|
-
type: "access",
|
|
463
|
-
level: 2,
|
|
464
|
-
rootPath: null,
|
|
465
|
-
context: null,
|
|
466
|
-
});
|
|
467
|
-
const cachedPathsWithContext = observerMap.getCachedPathsWithContext();
|
|
468
|
-
// Verify root structure
|
|
469
|
-
expect(cachedPathsWithContext["root"]).toBeDefined();
|
|
470
|
-
expect(cachedPathsWithContext["root"].type).toEqual("default");
|
|
471
|
-
const root = cachedPathsWithContext["root"];
|
|
472
|
-
// Verify items repeat structure
|
|
473
|
-
expect(root.paths["items"]).toBeDefined();
|
|
474
|
-
const items = root.paths["items"];
|
|
475
|
-
expect(items.type).toEqual("repeat");
|
|
476
|
-
expect(items.context).toEqual("item");
|
|
477
|
-
// Verify item.a access path
|
|
478
|
-
expect(items.paths["item.a"]).toBeDefined();
|
|
479
|
-
const itemA = items.paths["item.a"];
|
|
480
|
-
expect(itemA.type).toEqual("access");
|
|
481
|
-
expect(itemA.relativePath).toEqual("item.a");
|
|
482
|
-
expect(itemA.absolutePath).toEqual("root.items.__index__.a");
|
|
483
|
-
// Verify users repeat structure under items
|
|
484
|
-
expect(items.paths["users"]).toBeDefined();
|
|
485
|
-
const users = items.paths["users"];
|
|
486
|
-
expect(users.type).toEqual("repeat");
|
|
487
|
-
expect(users.context).toEqual("user");
|
|
488
|
-
// Verify user.name access path
|
|
489
|
-
expect(users.paths["user.name"]).toBeDefined();
|
|
490
|
-
const userName = users.paths["user.name"];
|
|
491
|
-
expect(userName.type).toEqual("access");
|
|
492
|
-
expect(userName.relativePath).toEqual("user.name");
|
|
493
|
-
expect(userName.absolutePath).toEqual("root.items.__index__.users.__index__.name");
|
|
494
|
-
// Verify badges repeat structure under users
|
|
495
|
-
expect(users.paths["badges"]).toBeDefined();
|
|
496
|
-
const badges = users.paths["badges"];
|
|
497
|
-
expect(badges.type).toEqual("repeat");
|
|
498
|
-
expect(badges.context).toEqual("badge");
|
|
499
|
-
// Verify badge access path
|
|
500
|
-
expect(badges.paths["badge"]).toBeDefined();
|
|
501
|
-
const badge = badges.paths["badge"];
|
|
502
|
-
expect(badge.type).toEqual("access");
|
|
503
|
-
expect(badge.relativePath).toEqual("badge");
|
|
504
|
-
expect(badge.absolutePath).toEqual("root.items.__index__.users.__index__.badges.__index__");
|
|
505
|
-
// Verify settings repeat structure under items (sibling to users)
|
|
506
|
-
expect(items.paths["settings"]).toBeDefined();
|
|
507
|
-
const settings = items.paths["settings"];
|
|
508
|
-
expect(settings.type).toEqual("repeat");
|
|
509
|
-
expect(settings.context).toEqual("setting");
|
|
510
|
-
// Verify setting.visibility access path
|
|
511
|
-
expect(settings.paths["setting.visibility"]).toBeDefined();
|
|
512
|
-
const settingVisibility = settings.paths["setting.visibility"];
|
|
513
|
-
expect(settingVisibility.type).toEqual("access");
|
|
514
|
-
expect(settingVisibility.relativePath).toEqual("setting.visibility");
|
|
515
|
-
expect(settingVisibility.absolutePath).toEqual("root.items.__index__.settings.__index__.visibility");
|
|
516
|
-
}));
|
|
517
|
-
test("should cache nested repeats with a path reference that belongs to the root parent context", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
518
|
-
/**
|
|
519
|
-
* Example:
|
|
520
|
-
* <f-repeat value="{{item in root.items}}">
|
|
521
|
-
* {{item.a}}
|
|
522
|
-
* <f-repeat value="{{user in item.users}}">
|
|
523
|
-
* {{user.name}}
|
|
524
|
-
* <f-repeat value="{{badge in user.badges}}">
|
|
525
|
-
* {{badge}}
|
|
526
|
-
* {{../../../selectedId}}
|
|
527
|
-
* </f-repeat>
|
|
528
|
-
* </f-repeat>
|
|
529
|
-
* </f-repeat>
|
|
530
|
-
*/
|
|
531
|
-
observerMap.cachePathWithContext({
|
|
532
|
-
path: "root.items",
|
|
533
|
-
self: false,
|
|
534
|
-
parentContext: null,
|
|
535
|
-
contextPath: "item",
|
|
536
|
-
type: "repeat",
|
|
537
|
-
level: 0,
|
|
538
|
-
rootPath: null,
|
|
539
|
-
context: null,
|
|
540
|
-
});
|
|
541
|
-
observerMap.cachePathWithContext({
|
|
542
|
-
path: "item.a",
|
|
543
|
-
self: true,
|
|
544
|
-
parentContext: "item",
|
|
545
|
-
contextPath: null,
|
|
546
|
-
type: "access",
|
|
547
|
-
level: 1,
|
|
548
|
-
rootPath: null,
|
|
549
|
-
context: null,
|
|
550
|
-
});
|
|
551
|
-
observerMap.cachePathWithContext({
|
|
552
|
-
path: "item.users",
|
|
553
|
-
self: true,
|
|
554
|
-
parentContext: "item",
|
|
555
|
-
contextPath: "user",
|
|
556
|
-
type: "repeat",
|
|
557
|
-
level: 1,
|
|
558
|
-
rootPath: null,
|
|
559
|
-
context: null,
|
|
560
|
-
});
|
|
561
|
-
observerMap.cachePathWithContext({
|
|
562
|
-
path: "user.name",
|
|
563
|
-
self: true,
|
|
564
|
-
parentContext: "user",
|
|
565
|
-
contextPath: null,
|
|
566
|
-
type: "access",
|
|
567
|
-
level: 2,
|
|
568
|
-
rootPath: null,
|
|
569
|
-
context: null,
|
|
570
|
-
});
|
|
571
|
-
observerMap.cachePathWithContext({
|
|
572
|
-
path: "user.badges",
|
|
573
|
-
self: true,
|
|
574
|
-
parentContext: "user",
|
|
575
|
-
contextPath: "badge",
|
|
576
|
-
type: "repeat",
|
|
577
|
-
level: 2,
|
|
578
|
-
rootPath: null,
|
|
579
|
-
context: null,
|
|
580
|
-
});
|
|
581
|
-
observerMap.cachePathWithContext({
|
|
582
|
-
path: "badge",
|
|
583
|
-
self: true,
|
|
584
|
-
parentContext: "badge",
|
|
585
|
-
contextPath: null,
|
|
586
|
-
type: "access",
|
|
587
|
-
level: 3,
|
|
588
|
-
rootPath: null,
|
|
589
|
-
context: null,
|
|
590
|
-
});
|
|
591
|
-
observerMap.cachePathWithContext({
|
|
592
|
-
path: "../../../selectedId",
|
|
593
|
-
self: true,
|
|
594
|
-
parentContext: "badge",
|
|
595
|
-
contextPath: null,
|
|
596
|
-
type: "access",
|
|
597
|
-
level: 3,
|
|
598
|
-
rootPath: null,
|
|
599
|
-
context: null,
|
|
600
|
-
});
|
|
601
|
-
const cachedPathsWithContext = observerMap.getCachedPathsWithContext();
|
|
602
|
-
// Verify root structure
|
|
603
|
-
expect(cachedPathsWithContext["root"]).toBeDefined();
|
|
604
|
-
expect(cachedPathsWithContext["root"].type).toEqual("default");
|
|
605
|
-
// Verify a nested item has been elevated to the root
|
|
606
|
-
expect(cachedPathsWithContext["selectedId"]).toBeDefined();
|
|
607
|
-
const selectedId = cachedPathsWithContext["selectedId"];
|
|
608
|
-
expect(selectedId.type).toEqual("access");
|
|
609
|
-
expect(selectedId.relativePath).toEqual("selectedId");
|
|
610
|
-
expect(selectedId.absolutePath).toEqual("selectedId");
|
|
611
|
-
}));
|
|
612
|
-
}));
|
|
613
19
|
}));
|