fix: handle leading comments in component templates - #445
Merged
Mohamed Mansour (mohamedmansour) merged 2 commits intoAug 14, 2026
Merged
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot started reviewing on behalf of
Mohamed Mansour (mohamedmansour)
August 14, 2026 20:48
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes component-template root classification when the authored content begins with leading HTML comments (e.g., license headers), which previously caused double-wrapping of an existing <template> and missed root metadata detection. The change introduces a shared, zero-copy “leading content” scan so multiple subsystems agree on what constitutes the first meaningful node.
Changes:
- Added
leading_content()scanner to skip leading whitespace and well-formed HTML comments and report the byte offset of the first non-comment content. - Updated root template classification call sites (template construction, component render policy parsing, runtime attribute detection, root event extraction) to use the shared scan.
- Added regression tests covering leading-comment scenarios for root detection and root policy parsing; updated docs-sync guidance to avoid docs churn for internal fixes restoring documented behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/webui-parser/src/html_parser.rs | Adds leading_content() utility to consistently skip leading whitespace/comments with an offset. |
| crates/webui-parser/src/lib.rs | Uses leading_content() for root template detection and runtime-attr detection; adds regression tests. |
| crates/webui-parser/src/component_policy.rs | Uses leading_content() so root render/hydration policy is detected after leading comments; adds a test. |
| crates/webui-parser/src/plugin/webui.rs | Uses leading_content() so root event extraction works when a leading comment precedes <template>. |
| .github/skills/docs-sync/SKILL.md | Clarifies docs-update guidance to avoid user-facing doc churn for internal regressions/refactors. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Mohamed Mansour (mohamedmansour)
requested review from
Bang Lee (Qusic),
Akrosh Gandhi (akroshg) and
mcritzjam
August 14, 2026 20:55
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Akrosh Gandhi (akroshg)
approved these changes
Aug 14, 2026
Mohamed Mansour (mohamedmansour)
merged commit Aug 14, 2026
92a25ab
into
microsoft:main
10 checks passed
Mohamed Mansour (mohamedmansour)
deleted the
mohamedmansour-fix-leading-comments
branch
August 14, 2026 21:52
Mohamed Mansour (mohamedmansour)
added a commit
that referenced
this pull request
Aug 15, 2026
## Release Bumps WebUI to `0.0.25`. Previous release tag: `v0.0.24` ## Changes since `v0.0.24` Fixes: - TypeScript consumers can import the framework and router together without conflicting `Window.__webui` declarations (fix: make WebUI global declarations compatible #444). - Component templates correctly classify authored roots and root metadata when leading copyright or license comments are present (fix: handle leading comments in component templates #445). - Router navigation distinguishes same-component route declarations by path, preserving declaration-specific pending, error, cache, and keep-alive behavior (fix: distinguish route declarations by path #446). ## Validation - `cargo xtask check` 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.
Component templates with copyright or license comments before their first authored node were misclassified, causing an existing
<template>wrapper to be wrapped again and preventing root metadata from being detected.This change adds a shared zero-copy scan that skips leading whitespace and HTML comments before root classification. Template construction, component render policy parsing, runtime attribute detection, and root event extraction now use the same semantics. Regression coverage includes a leading comment followed by an authored template, an element, or text, plus root policy and event metadata cases.
The docs synchronization guidance now avoids user-facing documentation churn for internal fixes that only restore already-documented behavior.