@microsoft/fast-html 1.0.0-alpha.21 → 1.0.0-alpha.23

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.
@@ -1,6 +1,6 @@
1
1
  import { __awaiter } from "tslib";
2
2
  import { expect, test } from "@playwright/test";
3
- import { Schema } from "./schema.js";
3
+ import { refPropertyName, Schema } from "./schema.js";
4
4
  test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
5
5
  test("should instantiate with a custom element name without throwing", () => __awaiter(void 0, void 0, void 0, function* () {
6
6
  expect(() => new Schema("my-custom-element")).not.toThrow();
@@ -18,7 +18,8 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
18
18
  path: "a",
19
19
  currentContext: null,
20
20
  parentContext: null,
21
- }
21
+ },
22
+ childrenMap: null,
22
23
  });
23
24
  const schemaA = schema.getSchema("a");
24
25
  expect(schemaA).not.toBe(null);
@@ -35,6 +36,7 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
35
36
  currentContext: null,
36
37
  parentContext: null,
37
38
  },
39
+ childrenMap: null,
38
40
  });
39
41
  let schemaA = schema.getSchema("a");
40
42
  expect(schemaA.properties).toBeDefined();
@@ -47,6 +49,7 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
47
49
  currentContext: null,
48
50
  parentContext: null,
49
51
  },
52
+ childrenMap: null,
50
53
  });
51
54
  schemaA = schema.getSchema("a");
52
55
  expect(schemaA.properties).toBeDefined();
@@ -65,6 +68,7 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
65
68
  currentContext: "item",
66
69
  parentContext: null,
67
70
  },
71
+ childrenMap: null,
68
72
  });
69
73
  const schemaA = schema.getSchema("items");
70
74
  expect(schemaA).toBeDefined();
@@ -75,8 +79,43 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
75
79
  expect((_b = schemaA.$defs) === null || _b === void 0 ? void 0 : _b["item"].$fast_context).toEqual("items");
76
80
  expect((_c = schemaA.$defs) === null || _c === void 0 ? void 0 : _c["item"].$fast_parent_contexts).toEqual([null]);
77
81
  }));
82
+ test("should add an object to a context in a schema", () => __awaiter(void 0, void 0, void 0, function* () {
83
+ var _d, _e, _f, _g, _h, _j;
84
+ const schema = new Schema("my-custom-element");
85
+ schema.addPath({
86
+ rootPropertyName: "items",
87
+ pathConfig: {
88
+ type: "repeat",
89
+ path: "items",
90
+ currentContext: "item",
91
+ parentContext: null,
92
+ },
93
+ childrenMap: null,
94
+ });
95
+ schema.addPath({
96
+ rootPropertyName: "items",
97
+ pathConfig: {
98
+ type: "default",
99
+ path: "item.a.b",
100
+ currentContext: "item",
101
+ parentContext: null,
102
+ },
103
+ childrenMap: null,
104
+ });
105
+ const schemaA = schema.getSchema("items");
106
+ expect(schemaA).toBeDefined();
107
+ expect(schemaA.$ref).toBeDefined();
108
+ expect(schemaA.$ref).toEqual("#/$defs/item");
109
+ expect(schemaA.type).toEqual("array");
110
+ expect((_d = schemaA.$defs) === null || _d === void 0 ? void 0 : _d["item"]).toBeDefined();
111
+ expect((_e = schemaA.$defs) === null || _e === void 0 ? void 0 : _e["item"].$fast_context).toEqual("items");
112
+ expect((_f = schemaA.$defs) === null || _f === void 0 ? void 0 : _f["item"].$fast_parent_contexts).toEqual([null]);
113
+ expect((_g = schemaA.$defs) === null || _g === void 0 ? void 0 : _g["item"].properties).toBeDefined();
114
+ expect((_h = schemaA.$defs) === null || _h === void 0 ? void 0 : _h["item"].properties["a"]).toBeDefined();
115
+ expect((_j = schemaA.$defs) === null || _j === void 0 ? void 0 : _j["item"].properties["a"].type).toEqual("object");
116
+ }));
78
117
  test("should add a nested context in a schema", () => __awaiter(void 0, void 0, void 0, function* () {
79
- var _d, _e, _f, _g, _h;
118
+ var _k, _l, _m, _o, _p;
80
119
  const schema = new Schema("my-custom-element");
81
120
  schema.addPath({
82
121
  rootPropertyName: "a",
@@ -86,6 +125,7 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
86
125
  currentContext: null,
87
126
  parentContext: null,
88
127
  },
128
+ childrenMap: null,
89
129
  });
90
130
  schema.addPath({
91
131
  rootPropertyName: "a",
@@ -95,17 +135,18 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
95
135
  currentContext: "item",
96
136
  parentContext: null,
97
137
  },
138
+ childrenMap: null,
98
139
  });
99
140
  const schemaA = schema.getSchema("a");
100
141
  expect(schemaA).toBeDefined();
101
- expect((_d = schemaA === null || schemaA === void 0 ? void 0 : schemaA.properties) === null || _d === void 0 ? void 0 : _d["items"]).toBeDefined();
102
- expect((_e = schemaA === null || schemaA === void 0 ? void 0 : schemaA.properties) === null || _e === void 0 ? void 0 : _e["items"].items.$ref).toEqual("#/$defs/item");
103
- expect((_f = schemaA.$defs) === null || _f === void 0 ? void 0 : _f["item"]).toBeDefined();
104
- expect((_g = schemaA.$defs) === null || _g === void 0 ? void 0 : _g["item"].$fast_context).toEqual("items");
105
- expect((_h = schemaA.$defs) === null || _h === void 0 ? void 0 : _h["item"].$fast_parent_contexts).toEqual([null]);
142
+ expect((_k = schemaA === null || schemaA === void 0 ? void 0 : schemaA.properties) === null || _k === void 0 ? void 0 : _k["items"]).toBeDefined();
143
+ expect((_l = schemaA === null || schemaA === void 0 ? void 0 : schemaA.properties) === null || _l === void 0 ? void 0 : _l["items"].items.$ref).toEqual("#/$defs/item");
144
+ expect((_m = schemaA.$defs) === null || _m === void 0 ? void 0 : _m["item"]).toBeDefined();
145
+ expect((_o = schemaA.$defs) === null || _o === void 0 ? void 0 : _o["item"].$fast_context).toEqual("items");
146
+ expect((_p = schemaA.$defs) === null || _p === void 0 ? void 0 : _p["item"].$fast_parent_contexts).toEqual([null]);
106
147
  }));
107
148
  test("should define an object as a nested context in a schema", () => __awaiter(void 0, void 0, void 0, function* () {
108
- var _j, _k, _l, _m, _o, _p, _q;
149
+ var _q, _r, _s, _t, _u, _v, _w;
109
150
  const schema = new Schema("my-custom-element");
110
151
  schema.addPath({
111
152
  rootPropertyName: "a",
@@ -115,6 +156,7 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
115
156
  currentContext: null,
116
157
  parentContext: null,
117
158
  },
159
+ childrenMap: null,
118
160
  });
119
161
  schema.addPath({
120
162
  rootPropertyName: "a",
@@ -124,6 +166,7 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
124
166
  currentContext: "item",
125
167
  parentContext: null,
126
168
  },
169
+ childrenMap: null,
127
170
  });
128
171
  schema.addPath({
129
172
  rootPropertyName: "a",
@@ -133,18 +176,19 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
133
176
  currentContext: "item",
134
177
  parentContext: null,
135
178
  },
179
+ childrenMap: null,
136
180
  });
137
181
  const schemaA = schema.getSchema("a");
138
182
  expect(schemaA).toBeDefined();
139
- expect((_j = schemaA.$defs) === null || _j === void 0 ? void 0 : _j["item"]).toBeDefined();
140
- expect((_k = schemaA.$defs) === null || _k === void 0 ? void 0 : _k["item"].$fast_context).toEqual("items");
141
- expect((_l = schemaA.$defs) === null || _l === void 0 ? void 0 : _l["item"].$fast_parent_contexts).toEqual([null]);
142
- expect((_m = schemaA.$defs) === null || _m === void 0 ? void 0 : _m["item"].type).toEqual("object");
143
- expect((_o = schemaA.$defs) === null || _o === void 0 ? void 0 : _o["item"].properties).toBeDefined();
144
- expect((_q = (_p = schemaA.$defs) === null || _p === void 0 ? void 0 : _p["item"].properties) === null || _q === void 0 ? void 0 : _q["b"]).toBeDefined();
183
+ expect((_q = schemaA.$defs) === null || _q === void 0 ? void 0 : _q["item"]).toBeDefined();
184
+ expect((_r = schemaA.$defs) === null || _r === void 0 ? void 0 : _r["item"].$fast_context).toEqual("items");
185
+ expect((_s = schemaA.$defs) === null || _s === void 0 ? void 0 : _s["item"].$fast_parent_contexts).toEqual([null]);
186
+ expect((_t = schemaA.$defs) === null || _t === void 0 ? void 0 : _t["item"].type).toEqual("object");
187
+ expect((_u = schemaA.$defs) === null || _u === void 0 ? void 0 : _u["item"].properties).toBeDefined();
188
+ expect((_w = (_v = schemaA.$defs) === null || _v === void 0 ? void 0 : _v["item"].properties) === null || _w === void 0 ? void 0 : _w["b"]).toBeDefined();
145
189
  }));
146
190
  test("should define nested contexts in a schema", () => __awaiter(void 0, void 0, void 0, function* () {
147
- var _r, _s, _t, _u, _v, _w;
191
+ var _x, _y, _z, _0, _1, _2;
148
192
  const schema = new Schema("my-custom-element");
149
193
  schema.addPath({
150
194
  rootPropertyName: "a",
@@ -154,6 +198,7 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
154
198
  currentContext: null,
155
199
  parentContext: null,
156
200
  },
201
+ childrenMap: null,
157
202
  });
158
203
  schema.addPath({
159
204
  rootPropertyName: "a",
@@ -163,6 +208,7 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
163
208
  currentContext: "user",
164
209
  parentContext: null,
165
210
  },
211
+ childrenMap: null,
166
212
  });
167
213
  schema.addPath({
168
214
  rootPropertyName: "a",
@@ -172,18 +218,19 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
172
218
  currentContext: "post",
173
219
  parentContext: "user"
174
220
  },
221
+ childrenMap: null,
175
222
  });
176
223
  const schemaA = schema.getSchema("a");
177
224
  expect(schemaA).toBeDefined();
178
- expect((_r = schemaA.$defs) === null || _r === void 0 ? void 0 : _r["user"]).toBeDefined();
179
- expect((_s = schemaA.$defs) === null || _s === void 0 ? void 0 : _s["user"].$fast_context).toEqual("users");
180
- expect((_t = schemaA.$defs) === null || _t === void 0 ? void 0 : _t["user"].$fast_parent_contexts).toEqual([null]);
181
- expect((_u = schemaA.$defs) === null || _u === void 0 ? void 0 : _u["post"]).toBeDefined();
182
- expect((_v = schemaA.$defs) === null || _v === void 0 ? void 0 : _v["post"].$fast_context).toEqual("posts");
183
- expect((_w = schemaA.$defs) === null || _w === void 0 ? void 0 : _w["post"].$fast_parent_contexts).toEqual([null, "user"]);
225
+ expect((_x = schemaA.$defs) === null || _x === void 0 ? void 0 : _x["user"]).toBeDefined();
226
+ expect((_y = schemaA.$defs) === null || _y === void 0 ? void 0 : _y["user"].$fast_context).toEqual("users");
227
+ expect((_z = schemaA.$defs) === null || _z === void 0 ? void 0 : _z["user"].$fast_parent_contexts).toEqual([null]);
228
+ expect((_0 = schemaA.$defs) === null || _0 === void 0 ? void 0 : _0["post"]).toBeDefined();
229
+ expect((_1 = schemaA.$defs) === null || _1 === void 0 ? void 0 : _1["post"].$fast_context).toEqual("posts");
230
+ expect((_2 = schemaA.$defs) === null || _2 === void 0 ? void 0 : _2["post"].$fast_parent_contexts).toEqual([null, "user"]);
184
231
  }));
185
232
  test("should define nested contexts with objects in a schema", () => __awaiter(void 0, void 0, void 0, function* () {
186
- var _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17;
233
+ var _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23;
187
234
  const schema = new Schema("my-custom-element");
188
235
  schema.addPath({
189
236
  rootPropertyName: "a",
@@ -193,6 +240,7 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
193
240
  currentContext: "user",
194
241
  parentContext: null,
195
242
  },
243
+ childrenMap: null,
196
244
  });
197
245
  schema.addPath({
198
246
  rootPropertyName: "a",
@@ -202,6 +250,7 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
202
250
  currentContext: "user",
203
251
  parentContext: null,
204
252
  },
253
+ childrenMap: null,
205
254
  });
206
255
  schema.addPath({
207
256
  rootPropertyName: "a",
@@ -211,6 +260,7 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
211
260
  currentContext: "post",
212
261
  parentContext: "user"
213
262
  },
263
+ childrenMap: null,
214
264
  });
215
265
  schema.addPath({
216
266
  rootPropertyName: "a",
@@ -220,6 +270,7 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
220
270
  currentContext: "post",
221
271
  parentContext: null,
222
272
  },
273
+ childrenMap: null,
223
274
  });
224
275
  schema.addPath({
225
276
  rootPropertyName: "a",
@@ -229,29 +280,206 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
229
280
  currentContext: "tag",
230
281
  parentContext: "post"
231
282
  },
283
+ childrenMap: null,
232
284
  });
233
285
  const schemaA = schema.getSchema("a");
234
286
  expect(schemaA).toBeDefined();
235
- expect((_x = schemaA.$defs) === null || _x === void 0 ? void 0 : _x["user"]).toBeDefined();
236
- expect((_y = schemaA.$defs) === null || _y === void 0 ? void 0 : _y["user"].$fast_context).toEqual("users");
237
- expect((_z = schemaA.$defs) === null || _z === void 0 ? void 0 : _z["user"].$fast_parent_contexts).toEqual([null]);
238
- expect((_0 = schemaA.$defs) === null || _0 === void 0 ? void 0 : _0["user"].type).toEqual("object");
239
- expect((_1 = schemaA.$defs) === null || _1 === void 0 ? void 0 : _1["user"].properties).toBeDefined();
240
- expect((_2 = schemaA.$defs) === null || _2 === void 0 ? void 0 : _2["user"].properties["a"]).toBeDefined();
241
- expect((_3 = schemaA.$defs) === null || _3 === void 0 ? void 0 : _3["user"].properties["a"].properties["b"]).toBeDefined();
242
- expect((_4 = schemaA.$defs) === null || _4 === void 0 ? void 0 : _4["post"]).toBeDefined();
243
- expect((_5 = schemaA.$defs) === null || _5 === void 0 ? void 0 : _5["post"].$fast_context).toEqual("posts");
244
- expect((_6 = schemaA.$defs) === null || _6 === void 0 ? void 0 : _6["post"].$fast_parent_contexts).toEqual([null, "user"]);
245
- expect((_7 = schemaA.$defs) === null || _7 === void 0 ? void 0 : _7["post"].type).toEqual("object");
246
- expect((_8 = schemaA.$defs) === null || _8 === void 0 ? void 0 : _8["post"].properties).toBeDefined();
247
- expect((_9 = schemaA.$defs) === null || _9 === void 0 ? void 0 : _9["post"].properties["c"]).toBeDefined();
248
- expect((_10 = schemaA.$defs) === null || _10 === void 0 ? void 0 : _10["post"].properties["c"].properties["d"]).toBeDefined();
249
- expect((_11 = schemaA.$defs) === null || _11 === void 0 ? void 0 : _11["post"].properties["meta"]).toBeDefined();
250
- expect((_12 = schemaA.$defs) === null || _12 === void 0 ? void 0 : _12["post"].properties["meta"].properties["tags"]).toBeDefined();
251
- expect((_13 = schemaA.$defs) === null || _13 === void 0 ? void 0 : _13["post"].properties["meta"].properties["tags"].items).toBeDefined();
252
- expect((_14 = schemaA.$defs) === null || _14 === void 0 ? void 0 : _14["post"].properties["meta"].properties["tags"].items.$ref).toEqual("#/$defs/tag");
253
- expect((_15 = schemaA.$defs) === null || _15 === void 0 ? void 0 : _15["tag"]).toBeDefined();
254
- expect((_16 = schemaA.$defs) === null || _16 === void 0 ? void 0 : _16["tag"].$fast_context).toEqual("tags");
255
- expect((_17 = schemaA.$defs) === null || _17 === void 0 ? void 0 : _17["tag"].$fast_parent_contexts).toEqual([null, "user", "post"]);
287
+ expect((_3 = schemaA.$defs) === null || _3 === void 0 ? void 0 : _3["user"]).toBeDefined();
288
+ expect((_4 = schemaA.$defs) === null || _4 === void 0 ? void 0 : _4["user"].$fast_context).toEqual("users");
289
+ expect((_5 = schemaA.$defs) === null || _5 === void 0 ? void 0 : _5["user"].$fast_parent_contexts).toEqual([null]);
290
+ expect((_6 = schemaA.$defs) === null || _6 === void 0 ? void 0 : _6["user"].type).toEqual("object");
291
+ expect((_7 = schemaA.$defs) === null || _7 === void 0 ? void 0 : _7["user"].properties).toBeDefined();
292
+ expect((_8 = schemaA.$defs) === null || _8 === void 0 ? void 0 : _8["user"].properties["a"]).toBeDefined();
293
+ expect((_9 = schemaA.$defs) === null || _9 === void 0 ? void 0 : _9["user"].properties["a"].properties["b"]).toBeDefined();
294
+ expect((_10 = schemaA.$defs) === null || _10 === void 0 ? void 0 : _10["post"]).toBeDefined();
295
+ expect((_11 = schemaA.$defs) === null || _11 === void 0 ? void 0 : _11["post"].$fast_context).toEqual("posts");
296
+ expect((_12 = schemaA.$defs) === null || _12 === void 0 ? void 0 : _12["post"].$fast_parent_contexts).toEqual([null, "user"]);
297
+ expect((_13 = schemaA.$defs) === null || _13 === void 0 ? void 0 : _13["post"].type).toEqual("object");
298
+ expect((_14 = schemaA.$defs) === null || _14 === void 0 ? void 0 : _14["post"].properties).toBeDefined();
299
+ expect((_15 = schemaA.$defs) === null || _15 === void 0 ? void 0 : _15["post"].properties["c"]).toBeDefined();
300
+ expect((_16 = schemaA.$defs) === null || _16 === void 0 ? void 0 : _16["post"].properties["c"].properties["d"]).toBeDefined();
301
+ expect((_17 = schemaA.$defs) === null || _17 === void 0 ? void 0 : _17["post"].properties["meta"]).toBeDefined();
302
+ expect((_18 = schemaA.$defs) === null || _18 === void 0 ? void 0 : _18["post"].properties["meta"].properties["tags"]).toBeDefined();
303
+ expect((_19 = schemaA.$defs) === null || _19 === void 0 ? void 0 : _19["post"].properties["meta"].properties["tags"].items).toBeDefined();
304
+ expect((_20 = schemaA.$defs) === null || _20 === void 0 ? void 0 : _20["post"].properties["meta"].properties["tags"].items.$ref).toEqual("#/$defs/tag");
305
+ expect((_21 = schemaA.$defs) === null || _21 === void 0 ? void 0 : _21["tag"]).toBeDefined();
306
+ expect((_22 = schemaA.$defs) === null || _22 === void 0 ? void 0 : _22["tag"].$fast_context).toEqual("tags");
307
+ expect((_23 = schemaA.$defs) === null || _23 === void 0 ? void 0 : _23["tag"].$fast_parent_contexts).toEqual([null, "user", "post"]);
308
+ }));
309
+ test("should define an anyOf with a $ref to another schema", () => __awaiter(void 0, void 0, void 0, function* () {
310
+ var _24;
311
+ const schema = new Schema("my-custom-element");
312
+ schema.addPath({
313
+ rootPropertyName: "a",
314
+ pathConfig: {
315
+ type: "default",
316
+ path: "a",
317
+ currentContext: null,
318
+ parentContext: null,
319
+ },
320
+ childrenMap: {
321
+ customElementName: "my-custom-element-2",
322
+ attributeName: "b",
323
+ },
324
+ });
325
+ const schemaA = schema.getSchema("a");
326
+ expect(schemaA).not.toBe(null);
327
+ expect(schemaA.$id).toEqual("https://fast.design/schemas/my-custom-element/a.json");
328
+ expect(schemaA.$schema).toEqual("https://json-schema.org/draft/2019-09/schema");
329
+ expect(schemaA.anyOf).not.toBeUndefined();
330
+ expect(schemaA.anyOf).toHaveLength(1);
331
+ expect((_24 = schemaA.anyOf) === null || _24 === void 0 ? void 0 : _24[0].$ref).toEqual("https://fast.design/schemas/my-custom-element-2/b.json");
332
+ }));
333
+ test("should define an anyOf with a $ref to multiple schemas", () => __awaiter(void 0, void 0, void 0, function* () {
334
+ var _25, _26;
335
+ const schema = new Schema("my-custom-element");
336
+ schema.addPath({
337
+ rootPropertyName: "a",
338
+ pathConfig: {
339
+ type: "default",
340
+ path: "a",
341
+ currentContext: null,
342
+ parentContext: null,
343
+ },
344
+ childrenMap: {
345
+ customElementName: "my-custom-element-2",
346
+ attributeName: "b",
347
+ },
348
+ });
349
+ schema.addPath({
350
+ rootPropertyName: "a",
351
+ pathConfig: {
352
+ type: "default",
353
+ path: "a",
354
+ currentContext: null,
355
+ parentContext: null,
356
+ },
357
+ childrenMap: {
358
+ customElementName: "my-custom-element-3",
359
+ attributeName: "c",
360
+ },
361
+ });
362
+ const schemaA = schema.getSchema("a");
363
+ expect(schemaA).not.toBe(null);
364
+ expect(schemaA.$id).toEqual("https://fast.design/schemas/my-custom-element/a.json");
365
+ expect(schemaA.$schema).toEqual("https://json-schema.org/draft/2019-09/schema");
366
+ expect(schemaA.anyOf).not.toBeUndefined();
367
+ expect(schemaA.anyOf).toHaveLength(2);
368
+ expect((_25 = schemaA.anyOf) === null || _25 === void 0 ? void 0 : _25[0].$ref).toEqual("https://fast.design/schemas/my-custom-element-2/b.json");
369
+ expect((_26 = schemaA.anyOf) === null || _26 === void 0 ? void 0 : _26[1].$ref).toEqual("https://fast.design/schemas/my-custom-element-3/c.json");
370
+ }));
371
+ test("should define an anyOf with a $ref to another schema in a nested object", () => __awaiter(void 0, void 0, void 0, function* () {
372
+ const schema = new Schema("my-custom-element");
373
+ schema.addPath({
374
+ rootPropertyName: "a",
375
+ pathConfig: {
376
+ type: "default",
377
+ path: "a.b",
378
+ currentContext: null,
379
+ parentContext: null,
380
+ },
381
+ childrenMap: null,
382
+ });
383
+ let schemaA = schema.getSchema("a");
384
+ schema.addPath({
385
+ rootPropertyName: "a",
386
+ pathConfig: {
387
+ type: "default",
388
+ path: "a.b.c",
389
+ currentContext: null,
390
+ parentContext: null,
391
+ },
392
+ childrenMap: {
393
+ customElementName: "my-custom-element-2",
394
+ attributeName: "test"
395
+ },
396
+ });
397
+ schemaA = schema.getSchema("a");
398
+ expect(schemaA.properties.b.properties.c).toBeDefined();
399
+ expect(schemaA.properties.b.properties.c.anyOf).not.toBeUndefined();
400
+ expect(schemaA.properties.b.properties.c.anyOf[0].$ref).toEqual("https://fast.design/schemas/my-custom-element-2/test.json");
401
+ }));
402
+ test("should define an anyOf with a $ref to multiple schemas in a nested object", () => __awaiter(void 0, void 0, void 0, function* () {
403
+ const schema = new Schema("my-custom-element");
404
+ schema.addPath({
405
+ rootPropertyName: "a",
406
+ pathConfig: {
407
+ type: "default",
408
+ path: "a.b",
409
+ currentContext: null,
410
+ parentContext: null,
411
+ },
412
+ childrenMap: null,
413
+ });
414
+ let schemaA = schema.getSchema("a");
415
+ schema.addPath({
416
+ rootPropertyName: "a",
417
+ pathConfig: {
418
+ type: "default",
419
+ path: "a.b.c",
420
+ currentContext: null,
421
+ parentContext: null,
422
+ },
423
+ childrenMap: {
424
+ customElementName: "my-custom-element-2",
425
+ attributeName: "test"
426
+ },
427
+ });
428
+ schema.addPath({
429
+ rootPropertyName: "a",
430
+ pathConfig: {
431
+ type: "default",
432
+ path: "a.b.c",
433
+ currentContext: null,
434
+ parentContext: null,
435
+ },
436
+ childrenMap: {
437
+ customElementName: "my-custom-element-3",
438
+ attributeName: "test-2"
439
+ },
440
+ });
441
+ schemaA = schema.getSchema("a");
442
+ expect(schemaA.properties.b.properties.c).toBeDefined();
443
+ expect(schemaA.properties.b.properties.c.anyOf).not.toBeUndefined();
444
+ expect(schemaA.properties.b.properties.c.anyOf[0].$ref).toEqual("https://fast.design/schemas/my-custom-element-2/test.json");
445
+ expect(schemaA.properties.b.properties.c.anyOf[1].$ref).toEqual("https://fast.design/schemas/my-custom-element-3/test-2.json");
446
+ }));
447
+ test("should define an anyOf with a $ref in a nested object in a context", () => __awaiter(void 0, void 0, void 0, function* () {
448
+ var _27, _28, _29, _30, _31, _32, _33, _34, _35;
449
+ const schema = new Schema("my-custom-element");
450
+ schema.addPath({
451
+ rootPropertyName: "a",
452
+ pathConfig: {
453
+ type: "repeat",
454
+ path: "a.users",
455
+ currentContext: "user",
456
+ parentContext: null,
457
+ },
458
+ childrenMap: null,
459
+ });
460
+ schema.addPath({
461
+ rootPropertyName: "a",
462
+ pathConfig: {
463
+ type: "access",
464
+ path: "user.a.b",
465
+ currentContext: "user",
466
+ parentContext: null,
467
+ },
468
+ childrenMap: {
469
+ customElementName: "my-custom-element-2",
470
+ attributeName: "c"
471
+ },
472
+ });
473
+ const schemaA = schema.getSchema("a");
474
+ expect(schemaA).toBeDefined();
475
+ expect((_27 = schemaA.$defs) === null || _27 === void 0 ? void 0 : _27["user"]).toBeDefined();
476
+ expect((_28 = schemaA.$defs) === null || _28 === void 0 ? void 0 : _28["user"].$fast_context).toEqual("users");
477
+ expect((_29 = schemaA.$defs) === null || _29 === void 0 ? void 0 : _29["user"].$fast_parent_contexts).toEqual([null]);
478
+ expect((_30 = schemaA.$defs) === null || _30 === void 0 ? void 0 : _30["user"].type).toEqual("object");
479
+ expect((_31 = schemaA.$defs) === null || _31 === void 0 ? void 0 : _31["user"].properties).toBeDefined();
480
+ expect((_32 = schemaA.$defs) === null || _32 === void 0 ? void 0 : _32["user"].properties["a"]).toBeDefined();
481
+ expect((_33 = schemaA.$defs) === null || _33 === void 0 ? void 0 : _33["user"].properties["a"].properties["b"]).toBeDefined();
482
+ expect((_34 = schemaA.$defs) === null || _34 === void 0 ? void 0 : _34["user"].properties["a"].properties["b"].anyOf).toHaveLength(1);
483
+ expect((_35 = schemaA.$defs) === null || _35 === void 0 ? void 0 : _35["user"].properties["a"].properties["b"].anyOf[0][refPropertyName]).toEqual("https://fast.design/schemas/my-custom-element-2/c.json");
256
484
  }));
257
485
  }));
@@ -22,7 +22,6 @@ class TemplateElement extends FASTElement {
22
22
  }
23
23
  constructor() {
24
24
  super();
25
- this.partials = {};
26
25
  // Ensure elementOptions is initialized if it's empty
27
26
  if (!TemplateElement.elementOptions ||
28
27
  Object.keys(TemplateElement.elementOptions).length === 0) {
@@ -120,7 +119,7 @@ class TemplateElement extends FASTElement {
120
119
  const updatedLevel = level + 1;
121
120
  const { repeat } = yield import("@microsoft/fast-element");
122
121
  rootPropertyName = getRootPropertyName(rootPropertyName, valueAttr[2], parentContext, behaviorConfig.name);
123
- const binding = bindingResolver(rootPropertyName, valueAttr[2], parentContext, behaviorConfig.name, schema, valueAttr[0], level);
122
+ const binding = bindingResolver(null, rootPropertyName, valueAttr[2], parentContext, behaviorConfig.name, schema, valueAttr[0], level);
124
123
  const { strings, values } = yield this.resolveStringsAndValues(rootPropertyName, innerHTML.slice(behaviorConfig.openingTagEndIndex, behaviorConfig.closingTagStartIndex), true, valueAttr[0], updatedLevel, schema, observerMap);
125
124
  externalValues.push(repeat((x, c) => binding(x, c), this.resolveTemplateOrBehavior(strings, values)));
126
125
  break;
@@ -185,7 +184,7 @@ class TemplateElement extends FASTElement {
185
184
  const type = "access";
186
185
  const propName = innerHTML.slice(behaviorConfig.openingEndIndex, behaviorConfig.closingStartIndex);
187
186
  rootPropertyName = getRootPropertyName(rootPropertyName, propName, parentContext, type);
188
- const binding = bindingResolver(rootPropertyName, propName, parentContext, type, schema, parentContext, level);
187
+ const binding = bindingResolver(strings.join(""), rootPropertyName, propName, parentContext, type, schema, parentContext, level);
189
188
  const contentBinding = (x, c) => binding(x, c);
190
189
  values.push(contentBinding);
191
190
  yield this.resolveInnerHTML(rootPropertyName, innerHTML.slice(behaviorConfig.closingEndIndex, innerHTML.length), strings, values, self, parentContext, level, schema, observerMap);
@@ -203,10 +202,10 @@ class TemplateElement extends FASTElement {
203
202
  const type = "event";
204
203
  rootPropertyName = getRootPropertyName(rootPropertyName, propName, parentContext, type);
205
204
  const arg = bindingHTML.slice(openingParenthesis + 1, closingParenthesis);
206
- const binding = bindingResolver(rootPropertyName, propName, parentContext, type, schema, parentContext, level);
205
+ const binding = bindingResolver(strings.join(""), rootPropertyName, propName, parentContext, type, schema, parentContext, level);
207
206
  const attributeBinding = (x, c) => binding(x, c).bind(x)(...(arg === "e" ? [c.event] : []), ...(arg !== "e" && arg !== ""
208
207
  ? [
209
- bindingResolver(rootPropertyName, arg, parentContext, type, schema, parentContext, level)(x, c),
208
+ bindingResolver(strings.join(""), rootPropertyName, arg, parentContext, type, schema, parentContext, level)(x, c),
210
209
  ]
211
210
  : []));
212
211
  values.push(attributeBinding);
@@ -215,7 +214,7 @@ class TemplateElement extends FASTElement {
215
214
  const propName = innerHTML.slice(behaviorConfig.openingEndIndex, behaviorConfig.closingStartIndex);
216
215
  const type = "access";
217
216
  rootPropertyName = getRootPropertyName(rootPropertyName, propName, parentContext, type);
218
- const binding = bindingResolver(rootPropertyName, propName, parentContext, type, schema, parentContext, level);
217
+ const binding = bindingResolver(strings.join(""), rootPropertyName, propName, parentContext, type, schema, parentContext, level);
219
218
  const attributeBinding = (x, c) => binding(x, c);
220
219
  values.push(attributeBinding);
221
220
  }