Conversation
…ssions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…te values Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…d README.md Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
5 tasks
…ay-length-in-expressions # Conflicts: # crates/microsoft-fast-build/src/directive.rs # crates/microsoft-fast-build/tests/custom_elements.rs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR fixes two data-access gaps in the microsoft-fast-build Rust renderer: enabling {{items.length}} for arrays in template expressions, and allowing JSON array/object literals to be passed directly via custom element attribute values.
Changes:
- Parse attribute values that look like JSON arrays/objects (
[/{) intoJsonValueinstead of always treating them as strings. - Add integration tests for JSON-literal attribute values passed into custom elements.
- Update docs to describe
.lengthsupport for arrays and the new attribute coercion rules.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/microsoft-fast-build/tests/custom_elements.rs | Adds integration tests covering JSON array/object literals in custom element attributes. |
| crates/microsoft-fast-build/src/directive.rs | Adds JSON-literal parsing branch to coerce attribute values into arrays/objects. |
| crates/microsoft-fast-build/README.md | Documents .length and attribute value coercion order (including JSON literals). |
| crates/microsoft-fast-build/DESIGN.md | Updates design notes for .length behavior and JSON-literal attribute coercion. |
| change/@microsoft-fast-build-fix-json-attrs-*.json | Adds patch change record for JSON literal attribute parsing. |
| change/@microsoft-fast-build-fix-array-length-*.json | Adds patch change record for array .length support. |
…SON parse Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
Fixes two gaps in the
microsoft-fast-buildRust renderer related to data access in template expressions:Array
.lengthsupport —{{items.length}}now resolves correctly. Previously,get_nested_propertytried to parse"length"as a numeric array index, which always failed and returned aMissingStateerror. A special case now returns the array's length as a number.JSON literal attribute values — Custom element attributes can now accept JSON array and object literals directly (e.g.
items='["a","b","c"]'orconfig='{"title":"Hello"}'). Previously, these were passed through as raw strings, causing child templates that iterated or accessed nested values to fail.🎫 Issues
{{users.length}}and{{user.orders.length}}{{user.posts.length}}📑 Test Plan
New Rust integration tests added:
tests/bindings.rs—test_array_length,test_array_length_empty,test_array_length_nestedtests/f_when.rs—test_when_array_length_gt_zero,test_when_array_length_zerotests/custom_elements.rs—test_custom_element_json_array_attr,test_custom_element_empty_array_attr,test_custom_element_json_object_attrAll existing and new tests pass (
cargo test).✅ Checklist
General
$ npm run change