Skip to content

fix(fast-build): :prop bindings forward typed state to child without rendering as HTML attribute#7395

Merged
janechu merged 1 commit intomainfrom
users/janechu/fix-json-literal-attributes
Apr 7, 2026
Merged

fix(fast-build): :prop bindings forward typed state to child without rendering as HTML attribute#7395
janechu merged 1 commit intomainfrom
users/janechu/fix-json-literal-attributes

Conversation

@janechu
Copy link
Copy Markdown
Collaborator

@janechu janechu commented Apr 6, 2026

Pull Request

📖 Description

Attributes with a : prefix (FAST property bindings) are now forwarded to the child element's SSR rendering state but are stripped from the rendered HTML output. Previously, :prop bindings were skipped entirely — not added to child state and not rendered in HTML.

This change enables structured data (arrays, objects) to be passed from the parent state to a custom element's SSR template — for use with f-repeat and similar directives — without the value appearing as a visible string attribute (e.g. [Object]) in the rendered HTML.

Attribute form In rendered HTML In child state
:items="{{items}}" ❌ stripped {"items": <array from parent state>}
items="{{items}}" ✅ rendered {"items": <array from parent state>}
@click="{handler()}" ❌ stripped ❌ skipped
f-ref, f-slotted, f-children ❌ stripped ❌ skipped

Example

<!-- entry.html -->
<item-list :items="{{items}}"></item-list>

<!-- templates.html -->
<f-template name="item-list">
  <template>
    <f-repeat value="{{item in items}}"><li>{{item}}</li></f-repeat>
  </template>
</f-template>

state.json supplies {"items": ["a", "b", "c"]}. The :items binding resolves the typed array from the parent state and places it in the child state without rendering it as an HTML attribute.

📑 Test Plan

  • test_custom_element_colon_property_in_state_not_html — verifies :prop resolves into child state and is absent from rendered HTML
  • test_custom_element_repeat_from_colon_binding — verifies f-repeat iterates an array passed via :prop
  • test_custom_element_repeat_empty_array_from_colon_binding — empty array case
  • test_custom_element_object_from_colon_binding — object passed via :prop resolves in child template

All existing tests pass (cargo test in crates/microsoft-fast-build).

✅ 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 added a commit that referenced this pull request Apr 6, 2026
The JSON array/object literal attribute parsing belongs on the fix-json-literal-attributes branch (PR #7395), not here.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
janechu added a commit that referenced this pull request Apr 6, 2026
The JSON array/object literal attribute parsing belongs on the fix-json-literal-attributes branch (PR #7395), not here.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@janechu janechu force-pushed the users/janechu/fix-json-literal-attributes branch from 0a6ad93 to c95a71a Compare April 7, 2026 03:52
@janechu janechu changed the title fix(fast-build): parse JSON array and object literals in HTML attribute values fix(fast-build): support f-repeat by passing arrays via {{binding}} expressions Apr 7, 2026
@janechu janechu marked this pull request as ready for review April 7, 2026 03:52
@janechu janechu force-pushed the users/janechu/fix-json-literal-attributes branch from 76b235b to 74d8f4b Compare April 7, 2026 04:02
@janechu janechu changed the title fix(fast-build): support f-repeat by passing arrays via {{binding}} expressions fix(fast-build): :prop bindings forward typed state to child without rendering as HTML attribute Apr 7, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates @microsoft/fast-build SSR custom element rendering so :prop (FAST property bindings) are forwarded into the child element’s SSR rendering state while being stripped from the emitted HTML, enabling typed values (arrays/objects) to flow into child templates (e.g., for f-repeat) without polluting attributes.

Changes:

  • Forward :prop bindings into custom element child state (lowercased key, : removed) while continuing to omit them from rendered HTML.
  • Add/adjust tests validating :prop typed forwarding (string/object/array) and verifying the attribute is absent from output HTML.
  • Update documentation (README + DESIGN) to reflect the new attribute-to-state behavior; add a patch change file.

Reviewed changes

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

Show a summary per file
File Description
crates/microsoft-fast-build/src/directive.rs Implements forwarding of :prop bindings into child SSR state while keeping @event skipped.
crates/microsoft-fast-build/tests/custom_elements.rs Adds coverage for :prop state forwarding (including arrays/objects for f-repeat) and stripping from HTML.
crates/microsoft-fast-build/README.md Updates attribute→state mapping and guidance for using :prop to pass structured data without rendering attributes.
crates/microsoft-fast-build/DESIGN.md Updates the SSR design notes to match the new :prop handling.
change/@microsoft-fast-build-fix-json-attrs-72c1b67a-84b2-484c-90bd-9e9f9a065e6c.json Adds a patch change entry for the behavior update.

…binding

f-repeat works with arrays passed via :prop={{binding}} expressions on the
custom element's opening tag. The binding resolves the array from the
parent state and forwards it as the child element's state entry, which
f-repeat then looks up by name.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@janechu janechu force-pushed the users/janechu/fix-json-literal-attributes branch from d049091 to 288f6f4 Compare April 7, 2026 04:10
@janechu janechu merged commit 41dc2d9 into main Apr 7, 2026
11 of 14 checks passed
@janechu janechu deleted the users/janechu/fix-json-literal-attributes branch April 7, 2026 04:18
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