@microsoft/fast-html 1.0.0-alpha.45 → 1.0.0-alpha.46

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.
@@ -44,6 +44,7 @@ export class Schema {
44
44
  else {
45
45
  if (!((_a = schema[defsPropertyName]) === null || _a === void 0 ? void 0 : _a[splitPath[0]])) {
46
46
  schema[defsPropertyName] = {
47
+ ...schema[defsPropertyName],
47
48
  [splitPath[0]]: {},
48
49
  };
49
50
  }
@@ -481,4 +481,47 @@ test.describe("Schema", async () => {
481
481
  expect((_h = schemaA.$defs) === null || _h === void 0 ? void 0 : _h["user"].properties["a"].properties["b"].anyOf).toHaveLength(1);
482
482
  expect((_j = schemaA.$defs) === null || _j === void 0 ? void 0 : _j["user"].properties["a"].properties["b"].anyOf[0][refPropertyName]).toEqual("https://fast.design/schemas/my-custom-element-2/c.json");
483
483
  });
484
+ test("should preserve existing $defs when adding a new dotted path inside a repeat context", async () => {
485
+ var _a, _b, _c, _d, _e;
486
+ // Regression test: Schema.addPath replaced $defs instead of merging
487
+ // when a dotted path (e.g. "entry.title") with a NEW context name was
488
+ // used after a prior context already populated $defs, destroying the
489
+ // first context's $defs entry.
490
+ // Real-world trigger: history_btr template with multiple repeat
491
+ // contexts where accessing a dotted path on a later context
492
+ // overwrites $defs.
493
+ const schema = new Schema("my-element");
494
+ // First repeat: creates $defs.group
495
+ schema.addPath({
496
+ rootPropertyName: "data",
497
+ pathConfig: {
498
+ type: "repeat",
499
+ path: "data.displayedGroups",
500
+ currentContext: "group",
501
+ parentContext: null,
502
+ },
503
+ childrenMap: null,
504
+ });
505
+ // Access a dotted path that targets a context NOT yet in $defs.
506
+ // splitPath = ["entry", "title"], and $defs["entry"] doesn't exist,
507
+ // so the code creates $defs = { entry: {} }, which SHOULD be
508
+ // $defs = { ...existing, entry: {} } to preserve "group".
509
+ schema.addPath({
510
+ rootPropertyName: "data",
511
+ pathConfig: {
512
+ type: "access",
513
+ path: "entry.title",
514
+ currentContext: "entry",
515
+ parentContext: "group",
516
+ },
517
+ childrenMap: null,
518
+ });
519
+ const schemaData = schema.getSchema("data");
520
+ expect(schemaData).toBeDefined();
521
+ // Both $defs entries must survive — the bug was that "group" was lost
522
+ expect((_a = schemaData.$defs) === null || _a === void 0 ? void 0 : _a["group"]).toBeDefined();
523
+ expect((_b = schemaData.$defs) === null || _b === void 0 ? void 0 : _b["entry"]).toBeDefined();
524
+ expect((_c = schemaData.$defs) === null || _c === void 0 ? void 0 : _c["group"].$fast_context).toEqual("displayedGroups");
525
+ expect((_e = (_d = schemaData.$defs) === null || _d === void 0 ? void 0 : _d["entry"].properties) === null || _e === void 0 ? void 0 : _e["title"]).toBeDefined();
526
+ });
484
527
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/fast-html",
3
- "version": "1.0.0-alpha.45",
3
+ "version": "1.0.0-alpha.46",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Microsoft",
@@ -29,8 +29,8 @@
29
29
  "dev": "concurrently -k -n tsc,server \"npm run watch\" \"npm run test-server\"",
30
30
  "doc:ci": "api-extractor run",
31
31
  "doc": "npm run doc:ci -- --local",
32
- "lint": "biome lint .",
33
- "lint:fix": "biome lint --fix .",
32
+ "lint": "biome-changed",
33
+ "lint:fix": "biome-changed -- --fix",
34
34
  "install-playwright-browsers": "npm run playwright install",
35
35
  "prepublishOnly": "npm run clean && npm run build",
36
36
  "test-server": "npx vite test/ --clearScreen false",
@@ -57,11 +57,11 @@
57
57
  "./dist/esm/index.js"
58
58
  ],
59
59
  "peerDependencies": {
60
- "@microsoft/fast-element": "^2.10.2"
60
+ "@microsoft/fast-element": "^2.10.3"
61
61
  },
62
62
  "devDependencies": {
63
- "@microsoft/fast-build": "^0.1.2",
64
- "@microsoft/fast-element": "^2.10.2"
63
+ "@microsoft/fast-build": "^0.3.0",
64
+ "@microsoft/fast-element": "^2.10.3"
65
65
  },
66
66
  "beachball": {
67
67
  "disallowedChangeTypes": [