Skip to content

Add repeat and when directive support to template generation in fast-test-harness#7632

Open
radium-v wants to merge 3 commits into
mainfrom
users/radium-v/generate-f-repeat-f-when
Open

Add repeat and when directive support to template generation in fast-test-harness#7632
radium-v wants to merge 3 commits into
mainfrom
users/radium-v/generate-f-repeat-f-when

Conversation

@radium-v

Copy link
Copy Markdown
Collaborator

Pull Request

📖 Description

Adds support to the FAST Test harness generator scripts for converting repeat and when directives into generated f-repeat and f-when output. WebUI template generation now converts those directives into WebUI for and if blocks, including nested repeat/when combinations.

This also expands related template conversion coverage for custom event bindings, slotted filters, children directives, and simple innerHTML bindings.

👩‍💻 Reviewer Notes

Please review the expression tracing used for simple when predicates and the directive-to-WebUI conversion path for nested f-when and f-repeat output.

📑 Test Plan

  • npm run test:node -w @microsoft/fast-test-harness passes with 106 tests.

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

Agents

  • I have linked to an existing issue in this project that this change addresses
  • I have read the skills
  • I have read the DESIGN.md file(s) in packages relevant to my changes
  • I have updated the DESIGN.md file(s) in packages relevant to my changes

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the @microsoft/fast-test-harness build-time template generators to recognize repeat / when constructs in compiled FAST templates and emit equivalent WebUI control-flow blocks, while expanding conversion coverage for additional binding patterns.

Changes:

  • Added WebUI conversion for <f-when> / <f-repeat> into <if> / <for> blocks during WebUI template generation.
  • Extended convertTemplate to reconstruct f-repeat / f-when output from compiled directive factories (including nested combinations).
  • Added/expanded node tests covering WebUI conversion, repeat/when conversion, custom events, elements() filters for slotted, and innerHTML wrapper handling.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/fast-test-harness/src/build/generate-webui-templates.ts Converts f-when/f-repeat tags in generated templates into WebUI <if>/<for> blocks.
packages/fast-test-harness/src/build/generate-webui-templates.test.ts Adds tests validating WebUI output for if/for conversion, including nesting.
packages/fast-test-harness/src/build/generate-templates.ts Adds directive reconstruction for repeat/when and expands expression normalization for bindings.
packages/fast-test-harness/src/build/generate-templates.test.ts Adds tests for repeat/when reconstruction, custom events, slotted elements() filters, and innerHTML handling.
change/@microsoft-fast-test-harness-2473cf9b-b505-47b0-900d-60dbeda05163.json Patch change file for the new directive support.
Comments suppressed due to low confidence (1)

packages/fast-test-harness/src/build/generate-templates.ts:237

  • This comment says the extracted filter elements(...) suffix applies to "slotted or children" directives, but the filter is only appended for SlottedDirective now. Updating the comment avoids misleading future maintainers.
/**
 * Extract the `filter elements(...)` suffix for a slotted or children
 * directive.
 */
Comment on lines +165 to +169
if (expression !== null) {
result += `<if condition="${expression}">`;
index = tagEnd + 1;
continue;
}
Comment on lines +179 to +183
if (expression !== null) {
result += `<for each="${expression}">`;
index = tagEnd + 1;
continue;
}
Comment on lines +43 to +45
const { html, ref, slotted, children, elements, repeat, when } = await import(
"@microsoft/fast-element"
);
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "add support for repeat and when directives",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"comment": "add support for repeat and when directives",
"comment": "Add support for repeat and when directives.",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants