Skip to content

feat: add declarativeTemplate bridge#7492

Merged
janechu merged 3 commits intoreleases/fast-element-v3from
copilot/pr3-declarative-template-bridge
Apr 24, 2026
Merged

feat: add declarativeTemplate bridge#7492
janechu merged 3 commits intoreleases/fast-element-v3from
copilot/pr3-declarative-template-bridge

Conversation

@janechu
Copy link
Copy Markdown
Collaborator

@janechu janechu commented Apr 24, 2026

Pull Request

📖 Description

This draft adds the public declarative template bridge so FAST elements can resolve DOM-authored <f-template> markup directly from template: declarativeTemplate() without a manual TemplateElement.define() step.

  • add zero-argument declarativeTemplate() on @microsoft/fast-element/declarative.js
  • introduce a registry-aware <f-template> bridge that waits for matching templates, handles template-first and definition-first ordering, and rejects duplicates clearly
  • keep TemplateElement as the component that parses markup, builds schema, applies map extensions, and creates the concrete ViewTemplate
  • migrate FAST-owned declarative fixtures/docs to the new authoring model while preserving the legacy templateOptions: "defer-and-hydrate" fallback

👩‍💻 Reviewer Notes

The main review points are the registry/name bucket logic in template-bridge.ts, the publication path in TemplateElement, and the error/compatibility handling around the retained legacy fallback.

📑 Test Plan

  • npm run build -w @microsoft/fast-element
  • npm run test:chromium -w @microsoft/fast-element
  • npm run checkchange
  • npm run biome:check
  • npm run build:tsc -w @microsoft/fast-element
  • cd packages/fast-element && npx playwright test src/declarative/template-bridge.pw.spec.ts src/components/fast-definitions.pw.spec.ts src/components/fast-element.pw.spec.ts --project=chromium

✅ 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.

⏭ Next Steps

The remaining follow-up is entrypoint cleanup for debug.js, declarative.js, and polyfills.js, followed by flipping @microsoft/fast-element to "sideEffects": false.

@janechu janechu force-pushed the copilot/pr2-declarative-map-extensions branch from e1d3d5f to b6a60e1 Compare April 24, 2026 16:14
@janechu janechu force-pushed the copilot/pr3-declarative-template-bridge branch 3 times, most recently from 7136abc to 27e9651 Compare April 24, 2026 16:50
@janechu janechu force-pushed the copilot/pr2-declarative-map-extensions branch from 4cb9375 to 6d29bb7 Compare April 24, 2026 17:19
@janechu janechu force-pushed the copilot/pr3-declarative-template-bridge branch from 27e9651 to 48ab602 Compare April 24, 2026 17:20
@janechu janechu force-pushed the copilot/pr2-declarative-map-extensions branch from 6d29bb7 to 79a0f5a Compare April 24, 2026 17:40
@janechu janechu force-pushed the copilot/pr3-declarative-template-bridge branch from 48ab602 to bd5d9fd Compare April 24, 2026 17:40
@janechu janechu force-pushed the copilot/pr2-declarative-map-extensions branch from 79a0f5a to a4b11b8 Compare April 24, 2026 19:30
@janechu janechu force-pushed the copilot/pr3-declarative-template-bridge branch from bd5d9fd to 9f05f56 Compare April 24, 2026 19:30
@janechu janechu force-pushed the copilot/pr2-declarative-map-extensions branch from a4b11b8 to 15a202c Compare April 24, 2026 19:41
@janechu janechu force-pushed the copilot/pr3-declarative-template-bridge branch from 9f05f56 to 85c2295 Compare April 24, 2026 19:42
@janechu janechu force-pushed the copilot/pr2-declarative-map-extensions branch from 15a202c to 9130dde Compare April 24, 2026 19:57
@janechu janechu force-pushed the copilot/pr3-declarative-template-bridge branch from 85c2295 to 108f340 Compare April 24, 2026 19:57
@janechu janechu force-pushed the copilot/pr2-declarative-map-extensions branch from 9130dde to 5972d45 Compare April 24, 2026 20:19
@janechu janechu force-pushed the copilot/pr3-declarative-template-bridge branch from 108f340 to cf5f14e Compare April 24, 2026 20:19
janechu added a commit that referenced this pull request Apr 24, 2026
# Pull Request

## 📖 Description

Adds a new **Declarative HTML** documentation section to the 3.x docs site with four pages covering the full declarative template authoring workflow:

- **Overview** — Purpose of declarative templates, when to use them, a hello world example, and comparison with imperative `html` tagged templates.
- **Writing f-templates** — Template syntax including content/attribute/boolean/event bindings, directives (`f-when`, `f-repeat`, `f-ref`, `f-slotted`, `f-children`), dot-notation paths, execution context access (`$e`, `$c`), and expression limitations.
- **Defining Elements** — `TemplateElement` registration, `templateOptions: "defer-and-hydrate"`, lifecycle callbacks (`config()`), element configuration (`options()`), `observerMap` and `attributeMap` usage.
- **Server-Side Rendering** — The renderer-agnostic SSR contract, hydration flow, Declarative Shadow DOM output, state propagation, and `@microsoft/fast-build` CLI usage.

Also adds cross-references from `packages/fast-element/README.md` and `DECLARATIVE_HTML.md` to the new docs.

Based on the declarative template features from PRs #7490, #7491, #7492, and #7493.

## 📑 Test Plan

- Website builds successfully with `npm run build -w sites/website`
- All four pages render correctly in the 11ty output
- `npm run checkchange` passes (no change files needed for docs-only changes to the website)

## ✅ Checklist

### General

- [x] I have included a change request file using `$ npm run change`
- [ ] I have added tests for my changes.
- [x] I have tested my changes.
- [x] I have updated the project documentation to reflect my changes.
- [x] I have read the [CONTRIBUTING](https://github.com/microsoft/fast/blob/main/CONTRIBUTING.md) documentation and followed the [standards](https://github.com/microsoft/fast/blob/main/CODE_OF_CONDUCT.md#our-standards) for this project.
@janechu janechu force-pushed the copilot/pr2-declarative-map-extensions branch from 5972d45 to 540ad04 Compare April 24, 2026 20:37
Base automatically changed from copilot/pr2-declarative-map-extensions to releases/fast-element-v3 April 24, 2026 21:31
janechu and others added 2 commits April 24, 2026 14:34
Introduce declarativeTemplate() and a registry-aware f-template publication bridge so FASTElement definitions can wait for DOM-authored templates without manual TemplateElement setup while preserving the legacy defer-and-hydrate fallback.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@janechu janechu force-pushed the copilot/pr3-declarative-template-bridge branch from cf5f14e to 1284755 Compare April 24, 2026 21:36
@janechu janechu marked this pull request as ready for review April 24, 2026 21:38
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@janechu janechu merged commit 247dfbf into releases/fast-element-v3 Apr 24, 2026
11 checks passed
@janechu janechu deleted the copilot/pr3-declarative-template-bridge branch April 24, 2026 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants