Skip to content

feat: add declarative map extensions#7491

Merged
janechu merged 6 commits intoreleases/fast-element-v3from
copilot/pr2-declarative-map-extensions
Apr 24, 2026
Merged

feat: add declarative map extensions#7491
janechu merged 6 commits intoreleases/fast-element-v3from
copilot/pr2-declarative-map-extensions

Conversation

@janechu
Copy link
Copy Markdown
Collaborator

@janechu janechu commented Apr 24, 2026

Pull Request

📖 Description

This draft moves declarative map configuration onto FASTElementDefinition so declarative authoring can use normal FAST element extensions instead of the global TemplateElement.options() setup.

  • add public observerMap() and attributeMap() helpers on @microsoft/fast-element/declarative.js
  • store declarative map options on the resolved element definition
  • have TemplateElement consume merged definition-scoped options while preserving TemplateElement.options() as a temporary fallback
  • migrate the extension-focused declarative fixtures and docs to the new helper-based authoring model

👩‍💻 Reviewer Notes

The key review points are the definition-scoped option plumbing in definition-options.ts and the merge/fallback behavior in TemplateElement. This PR intentionally stops short of the later declarativeTemplate() bridge.

📑 Test Plan

  • npm run build:tsc -w @microsoft/fast-element
  • npm run build:fixtures -w @microsoft/fast-element
  • npm run doc -w @microsoft/fast-element
  • npm run doc:exports -w @microsoft/fast-element
  • cd packages/fast-element && npx playwright test --config=playwright.declarative.config.ts --project=chromium test/declarative/fixtures/extensions
  • npx @biomejs/biome check --colors=off packages/fast-element/src/declarative/attribute-map.ts packages/fast-element/src/declarative/definition-options.ts packages/fast-element/src/declarative/index.ts packages/fast-element/src/declarative/observer-map.ts packages/fast-element/src/declarative/template.ts packages/fast-element/test/declarative/fixtures/extensions/attribute-map-naming-strategy/main.ts packages/fast-element/test/declarative/fixtures/extensions/attribute-map/main.ts packages/fast-element/test/declarative/fixtures/extensions/observer-map-config-object/main.ts packages/fast-element/test/declarative/fixtures/extensions/observer-map-deep-merge/main.ts packages/fast-element/test/declarative/fixtures/extensions/observer-map-properties/main.ts packages/fast-element/test/declarative/fixtures/extensions/observer-map/main.ts
  • npm run checkchange -- --since 15b9fa630 --no-fetch

✅ 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

A follow-up draft will teach <f-template> / declarativeTemplate() to resolve templates through this definition-scoped configuration path.

@janechu janechu force-pushed the copilot/pr2-declarative-map-extensions branch 3 times, most recently from 6d29bb7 to 79a0f5a Compare April 24, 2026 17:40
@janechu janechu force-pushed the copilot/pr2-declarative-map-extensions branch 4 times, most recently from 9130dde to 5972d45 Compare April 24, 2026 20:19
@janechu janechu changed the base branch from copilot/pr1-core-template-resolver to releases/fast-element-v3 April 24, 2026 20:21
@janechu janechu marked this pull request as ready for review April 24, 2026 20:21
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 and others added 6 commits April 24, 2026 13:36
Expose observerMap() and attributeMap() as FASTElement extensions and plumb definition-scoped declarative options through TemplateElement with the existing global options path kept as a temporary fallback.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove the explicit "all" map option so observerMap() and attributeMap() use the default behavior when no config object is passed, and update the declarative docs/examples to match.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Update the website's 3.x declarative API docs to reflect the removal of AttributeMapOption and ObserverMapOption and the new default map-option behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Fix the remaining declarative architecture examples that still referenced the removed explicit "all" map option.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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/pr2-declarative-map-extensions branch from 5972d45 to 540ad04 Compare April 24, 2026 20:37
@janechu janechu merged commit 287ae1b into releases/fast-element-v3 Apr 24, 2026
11 checks passed
@janechu janechu deleted the copilot/pr2-declarative-map-extensions branch April 24, 2026 21:31
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.

1 participant