Skip to content

fix: initialize child bindings before connection#329

Open
mohamedmansour wants to merge 1 commit into
mainfrom
mohamedmansour/fix-client-binding-lifecycle
Open

fix: initialize child bindings before connection#329
mohamedmansour wants to merge 1 commit into
mainfrom
mohamedmansour/fix-client-binding-lifecycle

Conversation

@mohamedmansour
Copy link
Copy Markdown
Contributor

@mohamedmansour mohamedmansour commented Jun 6, 2026

Summary

Changed the WebUI browser runtime so new client-created child components receive parent :prop values before their connectedCallback() runs.

Before, when a parent was created in the browser, WebUI appended child elements to the DOM first. That caused the child's connectedCallback() to run before the parent pushed bound properties like :value="{{val}}". Then the parent's first binding pass could overwrite whatever fallback the child set.

Now the runtime:

  1. Builds the parent's template in a detached staging wrapper.
  2. Upgrades child custom elements while still detached.
  3. Wires and applies the first binding pass there.
  4. Only then appends the DOM to the real page, triggering child connectedCallback() with initial bindings already available.

I also fixed tricky repeat/conditional cases so this still works when children are created later by <if> or <for>, including nested repeats and keyed reorder cases.

Closes #324

Validation

  • pnpm --dir packages/webui-framework test
  • pnpm --dir docs build
  • cargo xtask check

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.

webui-framework: parent attribute bindings overwrite child writes from connectedCallback

1 participant