Skip to content

fix: hydrate strict event arguments in repeat scopes - #322

Merged
Mohamed Mansour (mohamedmansour) merged 2 commits into
mainfrom
mmansour/strict-event-args
Jun 5, 2026
Merged

fix: hydrate strict event arguments in repeat scopes#322
Mohamed Mansour (mohamedmansour) merged 2 commits into
mainfrom
mmansour/strict-event-args

Conversation

@mohamedmansour

@mohamedmansour Mohamed Mansour (mohamedmansour) commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Tighten WebUI event handler argument parsing so malformed calls fail at compile time instead of being silently normalized.
  • Align @microsoft/webui-framework with the new strict event metadata contract: argSpecs arrays only, event target paths embedded in e[], and no legacy needsEvent / el[] compatibility path.
  • Fix SSR hydration for scoped event arguments in repeated blocks, including multi-root repeat bodies and initially empty text bindings.
  • Update DESIGN.md, docs/, and framework docs to describe the new event hydration and argument-resolution behavior.

Why

PR #317 added support for passing repeat-scope values to event handlers. Since that change is already merged to main and backward compatibility is not required, this follow-up locks down the new contract, rejects ambiguous handler syntax, and ensures SSR hydration wires scoped event handlers consistently.

Validation

  • cargo test -p microsoft-webui-parser
  • cd packages/webui-framework && pnpm test:unit && pnpm typecheck:e2e && pnpm exec playwright test tests/fixtures/list/list.spec.ts
  • cd docs && pnpm build
  • cargo xtask check

Tighten event argument parsing and hydrate multi-root repeat events without legacy metadata support.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mohamedmansour Mohamed Mansour (mohamedmansour) changed the title Fix strict event argument hydration fix: hydrate strict event arguments in repeat scopes Jun 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 tightens the cross-layer event binding contract (parser output → template metadata types → framework hydration) by making event handler arguments strictly parsed and consistently encoded, and by improving SSR hydration for repeat-scope event arguments and tricky repeat bodies.

Changes:

  • Enforce strict event handler syntax in the Rust compiler (reject trailing tokens, invalid handler names, malformed args) and emit argSpecs as arrays consistently.
  • Remove legacy event metadata shapes in the framework types/docs and embed event target paths directly in e[] entries.
  • Fix SSR hydration edge cases: repeat-scoped event argument wiring in repeat blocks (including multi-root repeat bodies) and initially-empty text bindings.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/webui-framework/src/template.ts Removes mention of legacy el event-target table from template meta docs.
packages/webui-framework/src/template-types.ts Makes CompiledEventArgs strictly an array shape (drops number legacy encoding).
packages/webui-framework/src/element.ts Updates SSR hydration logic (text-node fallback insertion, repeat multi-root hydration path) and optimizes event listener wiring for common arg shapes.
packages/webui-framework/RENDERING.md Updates runtime metadata documentation to reflect e[] carrying both args and target paths.
packages/webui-framework/README.md Updates public docs/examples to the new strict event-call syntax and event metadata encoding.
docs/guide/concepts/interactivity.md Documents repeat-scope values and supported event handler argument forms.
docs/guide/concepts/how-it-works.md Notes that events are attached with compiled argument scopes during hydration.
docs/ai.md Updates AI reference examples and guidance for event handler arguments and repeat-scope support.
DESIGN.md Updates the specification to match the new event metadata and hydration behavior.
crates/webui-parser/src/plugin/webui.rs Implements strict event handler parsing, validates handler/path grammar, updates root-event encoding, and adds regression tests.

Comment thread packages/webui-framework/src/element.ts
Comment thread packages/webui-framework/src/element.ts
Use template-aware ordinal lookup when inserting missing SSR text nodes and document trusted marker-stream invariants.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mohamedmansour
Mohamed Mansour (mohamedmansour) merged commit c0bd525 into main Jun 5, 2026
21 checks passed
@mohamedmansour
Mohamed Mansour (mohamedmansour) deleted the mmansour/strict-event-args branch June 5, 2026 20:28
Mohamed Mansour (mohamedmansour) added a commit that referenced this pull request Jun 8, 2026
Clusters:
- feat: parser comment policy strips template/style comments while preserving legal comments, with CLI, Node, docs, and benchmark coverage (#326, b513efb).
- feat: CSS module delivery now emits import-map data URI modules and the commerce demo defaults to module styles (#325, #327, f5cedc3, 88fc307).
- fix: repeat-scope event arguments hydrate correctly for framework bindings, including strict argument handling (#317, #322, 11b6a6d, c0bd525).
- fix: client binding lifecycle ordering preserves child updates across conditional and repeated DOM paths (#329, 0f40666).
- fix: compiled templates preserve raw style text instead of altering author-provided CSS content (#330, 4db730a).
- docs: issue forms, contribution/support policy, framework rendering docs, CLI docs, and integration guides were refreshed (#321, #328, plus docs in #322/#325/#326/#329; 6853b4c, f97bdc6).

Release bump:
- Update Rust workspace crates, internal crate dependency constraints, Cargo.lock package versions, npm packages, platform packages, router/framework/test-support packages, and .NET Directory.Build.props from 0.0.14 to 0.0.15.

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.

3 participants