Skip to content

chore(fast-html): use @microsoft/fast-build to build observer-map fixture#7388

Draft
janechu wants to merge 13 commits intomainfrom
users/janechu/update-fixture-to-use-fast-build-observer-map
Draft

chore(fast-html): use @microsoft/fast-build to build observer-map fixture#7388
janechu wants to merge 13 commits intomainfrom
users/janechu/update-fixture-to-use-fast-build-observer-map

Conversation

@janechu
Copy link
Copy Markdown
Collaborator

@janechu janechu commented Apr 4, 2026

Pull Request

📖 Description

Migrates the observer-map fixture in @microsoft/fast-html to be built by @microsoft/fast-build (the Rust/WASM SSR tool), consistent with other fixture migrations in this series.

Key changes:

  • Adds "observer-map" to the build-fixtures.js fixture list
  • Adds entry.html, state.json, and templates.html for the fixture
  • Cleans up redundant {{binding}} attrs on entry elements where the property name already matches the state.json key (root state is passed implicitly)
  • Remaps items via :items="{{simpleItems}}" since the state key (simpleItems) differs from the property name (items)
  • Keeps selected-user-id="{{selectedUserId}}" since the HTML attribute name differs from the JS property name
  • Regenerates index.html via npm run build:fixtures

📑 Test Plan

All existing tests pass. The fixture builds successfully via npm run build:fixtures.

✅ 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

Continue migrating remaining fixtures to use @microsoft/fast-build.

@janechu
Copy link
Copy Markdown
Collaborator Author

janechu commented Apr 6, 2026

Updated to pass a, x, and groups through the observer-map element chain. Now builds successfully with renderer fixes in #7394 (.length on arrays) and #7396 (kebab-to-camelCase + property bindings).

@janechu janechu force-pushed the users/janechu/update-fixture-to-use-fast-build-observer-map branch from 2e0e8b6 to c4f3083 Compare April 8, 2026 19:42
janechu added a commit that referenced this pull request Apr 8, 2026
…ssions (#7394)

# Pull Request

## 📖 Description

Fixes two gaps in the `microsoft-fast-build` Rust renderer related to data access in template expressions:

1. **Array `.length` support** — `{{items.length}}` now resolves correctly. Previously, `get_nested_property` tried to parse `"length"` as a numeric array index, which always failed and returned a `MissingState` error. A special case now returns the array's length as a number.

2. **JSON literal attribute values** — Custom element attributes can now accept JSON array and object literals directly (e.g. `items='["a","b","c"]'` or `config='{"title":"Hello"}'`). Previously, these were passed through as raw strings, causing child templates that iterated or accessed nested values to fail.

### 🎫 Issues

* Helps unblock [#7390](#7390) — deep-merge fixture uses `{{users.length}}` and `{{user.orders.length}}`
* Helps unblock [#7388](#7388) — observer-map fixture uses `{{user.posts.length}}`

## 📑 Test Plan

New Rust integration tests added:

- `tests/bindings.rs` — `test_array_length`, `test_array_length_empty`, `test_array_length_nested`
- `tests/f_when.rs` — `test_when_array_length_gt_zero`, `test_when_array_length_zero`
- `tests/custom_elements.rs` — `test_custom_element_json_array_attr`, `test_custom_element_empty_array_attr`, `test_custom_element_json_object_attr`

All existing and new tests pass (`cargo test`).

## ✅ Checklist

### General

- [x] I have included a change request file using `$ npm run change`
- [x] 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 janechu force-pushed the users/janechu/update-fixture-to-use-fast-build-observer-map branch from 1e4cc26 to ef17c88 Compare April 8, 2026 22:50
janechu added a commit that referenced this pull request Apr 9, 2026
…er (#7410)

# Pull Request

## 📖 Description

Fixes a bug in the hand-rolled JSON string parser (`json.rs`) where non-ASCII characters were corrupted during parsing.

The `parse_string` function advanced through the input byte-by-byte and used `b as char` for unescaped characters. For ASCII bytes this is correct, but for multi-byte UTF-8 sequences it casts each byte independently to a Unicode scalar, producing garbage. For example, ⭐ (U+2B50, UTF-8: `0xE2 0xAD 0x90`) was rendered as `â` (U+00E2) followed by two invisible control characters.

The fix determines the byte-length of each UTF-8 sequence from the leading byte, reads the full sequence, and decodes it with `std::str::from_utf8`. ASCII bytes (< 0x80) continue to use the fast `b as char` path.

This explains the `â SELECTED` corruption observed in the observer-map fixture output (issue seen in #7388).

## 📑 Test Plan

New unit tests in `json.rs`:
- `test_parse_string_with_emoji` — ⭐ round-trips correctly
- `test_parse_string_with_multibyte_chars` — 2-byte (é), 3-byte (✓), and 4-byte (🎉) sequences
- `test_parse_string_emoji_in_object` — emoji values inside a JSON object

New integration tests in `tests/bindings.rs`:
- `test_binding_emoji_from_state` — emoji from JSON state renders correctly in a binding
- `test_binding_emoji_literal_in_template` — emoji in template literal text is preserved verbatim
- `test_binding_multibyte_chars` — general multi-byte character round-trip

All existing tests pass (`cargo test`).

## ✅ Checklist

### General

- [ ] I have included a change request file using `$ npm run change`
- [x] 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 12 commits April 8, 2026 22:33
…ture

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…p element chain

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ry attrs

Rebase onto main (includes all previous fixtures up to performance-metrics).
Resolved build-fixtures.js conflict by appending 'observer-map'.

Remove redundant {{binding}} attrs where property name matches state.json key
(users, stats, a, x, groups, value1, value2). Change items="{{simpleItems}}"
to :items="{{simpleItems}}" since 'simpleItems' remaps to 'items'. Keep
selected-user-id="{{selectedUserId}}" as the HTML attr name differs from the
JS property name.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…bserver-map entry

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…element

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Change all camelCase property/state keys to lowercase in state.json,
entry.html, templates.html, and main.ts:
- simpleItems → simpleitems
- selectedUserId → selecteduserid (remove duplicate key from state.json)
- totalUsers → totalusers
- activeUsers → activeusers
- loadTime → loadtime
- renderTime → rendertime

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…pInternalTestElement

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…Element

Keep property declarations on ObserverMapInternalTestElement without
initial values so they are set via template binding from the parent.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…tElement

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…InternalTestElement

Let observerMap: all handle change detection for these properties,
including deep nested mutations after replacement.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…pTestElement

Add simpleitems, value1, value2, totalusers, metrics properties.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… and x=undefined on class

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@janechu janechu force-pushed the users/janechu/update-fixture-to-use-fast-build-observer-map branch from 6997b47 to dc0420d Compare April 9, 2026 05:36
…outer template

The outer template no longer passes :a and :x to the inner element.
These are protected by f-when in the inner template (a=null in state.json),
so the SSR build does not evaluate {{a.b.c}} or {{x.y.z}}.

ObserverMap sets up property tracking from class instantiation on the
inner element's own a={} and x=undefined fields. Passing :a and :x via
parent template bindings overwrote the inner element's class fields after
instantiation, preventing ObserverMap from re-subscribing to deep paths
(e.g. a.b.c) after property replacement.

:groups is kept as an explicit binding because the current build tool
requires all f-repeat sources to be present in the element's state context.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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