feat(router): parse query params and pass to components as attributes#237
Merged
mohamedmansour merged 2 commits intomainfrom Apr 15, 2026
Merged
feat(router): parse query params and pass to components as attributes#237mohamedmansour merged 2 commits intomainfrom
mohamedmansour merged 2 commits intomainfrom
Conversation
Contributor
mohamedmansour
commented
Apr 14, 2026
- Add parseQuery() helper to extract URLSearchParams from request paths
- Include 'query' field in NavigationEvent dispatched on navigation
- Pass query params as kebab-case attributes on mounted/re-applied components
- Add page-compose fixture with @attr fields for query param testing
- Add 7 unit tests for parseQuery (empty, single, multiple, encoded, dupes)
- Add 3 E2E tests: SSR render, client-side attr flow, navigated event query
- Update router README and docs/guide/ai.md with query param documentation
- All 32 unit tests + 11 E2E tests pass
janechu
previously approved these changes
Apr 14, 2026
d2d6432 to
1941989
Compare
Parse URL query parameters and forward them as component attributes, gated by a deny-by-default allowlist declared on <route> elements: <route path="compose" component="page-compose" query="action,to,subject" /> Full-stack implementation across proto schema, parser, handler, and TS router. Only params listed in the query attribute are set as DOM attributes; unlisted params are silently dropped. Route params always take priority over query params (kebab-case collision check), and stale query-param attributes are removed on re-navigation. The NavigationEvent.query field exposes all URL query params (unfiltered) for programmatic JS consumers. Also in this commit: - Handle non-JSON server responses gracefully in fetchPartial by checking Content-Type before parsing; falls back to full page navigation for HTML responses (e.g. login redirects) - Add View Transitions API documentation to README and docs/guide - Add page-compose fixture with @attr fields for E2E testing - Add 14 unit tests (parseQuery + filterQuery) and 5 E2E tests (SSR render, client-side attr flow, allowlist enforcement, navigated event query, unfiltered event verification) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
410d533 to
43237b3
Compare
- Add Rust tests for allowed_query across the stack: - Protocol: round-trip with non-empty allowed_query - Parser: query attribute parsed into allowed_query field - Handler: matched/non-matched routes emit query attr in SSR - Handler: RouteChainEntry.to_json includes/omits allowedQuery - Handler: collect_route_chain carries allowed_query through - Update DESIGN.md with allowed_query proto field and query attr docs - Update VitePress docs: route.md, routing.md, ai.md with query attr - Extract toKebab to module-level helper (was duplicated 3x) - Add abort guard before content-type redirect in fetchPartial - Fix fetch mocks in unit tests to include headers for content-type check Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
43237b3 to
15a3987
Compare
toddreifsteck
approved these changes
Apr 15, 2026
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.