Skip to content

refactor: modularize Schema, ObserverMap, and AttributeMap in fast-html#7478

Merged
janechu merged 2 commits intoreleases/fast-element-v3from
users/janechu/modularize-the-template-element-schema-maps
Apr 22, 2026
Merged

refactor: modularize Schema, ObserverMap, and AttributeMap in fast-html#7478
janechu merged 2 commits intoreleases/fast-element-v3from
users/janechu/modularize-the-template-element-schema-maps

Conversation

@janechu
Copy link
Copy Markdown
Collaborator

@janechu janechu commented Apr 22, 2026

Pull Request

📖 Description

Modularize Schema, ObserverMap, and AttributeMap in @microsoft/fast-html to reduce tight coupling with TemplateElement. This is a breaking change.

Key changes:

  • Moved ObserverMapConfig, ObserverMapPathEntry, ObserverMapPathNode, and ObserverMapOption from template.ts to observer-map.ts
  • Moved AttributeMapConfig and AttributeMapOption from template.ts to attribute-map.ts
  • Replaced Schema.jsonSchemaMap (static property) with an instance-level schemaMap and a module-level schemaRegistry export for cross-element $ref resolution
  • Added Schema, AttributeMap, schemaRegistry, JSONSchema, and CachedPathMap to the public API exports
  • Reversed the dependency direction: template.ts now imports from observer-map.ts and attribute-map.ts, instead of the other way around

👩‍💻 Reviewer Notes

The module dependency direction is now:

template.ts ──imports──▶ observer-map.ts (config types)
template.ts ──imports──▶ attribute-map.ts (config types)
template.ts ──imports──▶ schema.ts
observer-map.ts ──imports──▶ schema.ts (types only)
attribute-map.ts ──imports──▶ schema.ts (types only)
utilities.ts ──imports──▶ schema.ts (schemaRegistry for cross-element $ref)

📑 Test Plan

All 873 existing tests pass across Chromium, Firefox, and WebKit. No new tests were needed as the refactor preserves all existing behavior — only the internal module boundaries and export surface changed.

✅ Checklist

General

  • I have included a change request file using $ npm run change
  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

@janechu janechu marked this pull request as ready for review April 22, 2026 18:30
@janechu janechu added the fast-element-v3 Pertains to fast-element-v3 label Apr 22, 2026
janechu and others added 2 commits April 22, 2026 14:03
Move configuration types and constants to their owning modules, reversing
the dependency direction so that observer-map.ts and attribute-map.ts no
longer import from template.ts:

- ObserverMapConfig, ObserverMapPathEntry, ObserverMapPathNode, and
  ObserverMapOption moved from template.ts to observer-map.ts
- AttributeMapConfig and AttributeMapOption moved from template.ts to
  attribute-map.ts
- Schema.jsonSchemaMap (static) replaced with instance-level schemaMap
  and module-level schemaRegistry for cross-element $ref resolution
- Schema, AttributeMap, schemaRegistry, JSONSchema, and CachedPathMap
  added to the public API exports
- Updated DESIGN.md, SCHEMA_OBSERVER_MAP.md, MIGRATION.md, and
  api-report

BREAKING CHANGE: Schema.jsonSchemaMap removed; use schemaRegistry export.
Config types now imported from their owning modules.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@janechu janechu force-pushed the users/janechu/modularize-the-template-element-schema-maps branch from dd95c17 to c926ac0 Compare April 22, 2026 21:03
@janechu janechu merged commit 23ca1fa into releases/fast-element-v3 Apr 22, 2026
11 checks passed
@janechu janechu deleted the users/janechu/modularize-the-template-element-schema-maps branch April 22, 2026 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fast-element-v3 Pertains to fast-element-v3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant