feat: add automatic HTML-only WebUI elements#377
Open
mohamedmansour wants to merge 7 commits into
Open
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep delegated event dispatch on the shared handler invocation path while exposing the bound element as event.currentTarget for handlers that receive e. Co-authored-by: Copilot App <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.
HTML-only WebUI components currently need empty
WebUIElementstubs just to preserve SSR state and accept router-driven updates. This adds compiler-marked auto-elements so declarative components can omit.tsfiles while still hydrating, observing attributes, and supportingsetState()when the framework needs to update them.Approach
ae:1only for filesystem-discovered.htmlcomponents without sibling.ts/.jsimplementations.installAutoElementRuntime(...)or maintain manual tag lists.CoreElementpath from interactiveWebUIElementfeatures so HTML-only components avoid event/ref/emit code when it can be tree-shaken.webui-routerplatform-independent by dispatching template-registration events instead of importing framework code.blockedTagsso loader-owned tags are never auto-claimed before authored modules define them.Review notes
The initial page auto-claim is deferred by one microtask so authored custom elements and router loader exclusions can register first. Router partial/template registrations still claim eligible templates synchronously after new template metadata arrives, before passive router stubs are needed.
Event wiring now uses delegated event buckets, with one listener per event name on the component render root and per-instance cleanup for removed conditional/repeat blocks. Complex
:child bindings now fall back to direct property assignment when a child WebUI element does not handle the key through decorated or template-only state, preserving authored non-observable setters.Bundle size
A follow-up cleanup removed compatibility-oriented delegated-event fallback code, reused the existing template-root analysis instead of shipping a second dynamic-template scanner/cache, and collapsed template-registration parsing.
Measured probe deltas from before the cleanup to after:
Validation
cargo checkcargo xtask checkpnpm --filter @microsoft/webui-framework typecheckpnpm --filter @microsoft/webui-framework test:unitpnpm --filter @microsoft/webui-framework typecheck:e2eplaywright test tests/fixtures/optional-template-state tests/fixtures/repeat-conditionalpnpm --filter @microsoft/webui-router typecheckpnpm --filter @microsoft/webui-router testcargo test -p microsoft-webui-parser --libcargo check -p microsoft-webui-parser --no-default-featuresAdditional note:
cargo xtask e2ewas run earlier; the functional suites passed, while existing visual screenshot baselines in contact-book/commerce and webui-press readiness checks still reported diffs/timeouts for separate follow-up.