Add repeat and when directive support to template generation in fast-test-harness#7632
Open
radium-v wants to merge 3 commits into
Open
Add repeat and when directive support to template generation in fast-test-harness#7632radium-v wants to merge 3 commits into
radium-v wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
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
convertTemplateto reconstructf-repeat/f-whenoutput 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 forSlottedDirectivenow. 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" | ||
| ); |
janechu
approved these changes
Jul 1, 2026
| @@ -0,0 +1,7 @@ | |||
| { | |||
| "type": "patch", | |||
| "comment": "add support for repeat and when directives", | |||
Collaborator
There was a problem hiding this comment.
Suggested change
| "comment": "add support for repeat and when directives", | |
| "comment": "Add support for repeat and when directives.", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
📖 Description
Adds support to the FAST Test harness generator scripts for converting
repeatandwhendirectives into generatedf-repeatandf-whenoutput. WebUI template generation now converts those directives into WebUIforandifblocks, including nested repeat/when combinations.This also expands related template conversion coverage for custom event bindings, slotted filters,
childrendirectives, and simpleinnerHTMLbindings.👩💻 Reviewer Notes
Please review the expression tracing used for simple
whenpredicates and the directive-to-WebUI conversion path for nestedf-whenandf-repeatoutput.📑 Test Plan
npm run test:node -w @microsoft/fast-test-harnesspasses with 106 tests.✅ Checklist
General
$ npm run changeAgents